Question: I am new in C-Sharp, i am trying to access my Database from C-Sharp, i have written the following code, and i dont know what to write next to view data. I have searched this on net but didnt get much. Kindly tell me this in easy code.

```
string connection = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=F:\Database3.accdb";

OleDbConnection conn = new OleDbConnection(connection);
conn.Open();
OleDbCommand cmd = new OleDbCommand("Select * from score", conn);

OleDbDataAdapter da = new OleDbDataAdapter(cmd);
da.SelectCommand = cmd;

```

Answer: 
**Refer following code:**

```
string strProvider = "@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=F:\Database3.accdb";
string strSql = "Select * from score";
OleDbConnection con = new OleDbConnection(strProvider);
OleDbCommand cmd = new OleDbCommand(strSql, con);
con.Open();
cmd.CommandType = CommandType.Text;
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
DataTable scores = new DataTable();
da.Fill(scores);
dataGridView1.DataSource = scores;

```

Hope its helpful.
Try this 

```
        try
        {

        Dataset myDataSet=new Dataset();

        string connection = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=F:\Database3.accdb";
        OleDbCommand cmd = new OleDbCommand("Select * from score", conn);
        OleDbDataAdapter myDataAdapter = new OleDbDataAdapter(cmd );

        connection .Open();
        myDataAdapter.Fill(myDataSet,"TableName");

        }
        catch (Exception ex)
        {
              Console.WriteLine("Error: Failed to retrieve the required data from the DataBase.\n{0}", ex.Message);
              return;
        }
        finally
        {
              connection .Close();
        }

```

Remember for good coding practice ,always connection should be open in **Try Block**
and closed in **Finally Block**