hey i am trying to connect database table with my form in C#
Here is my code....

private void btn_quiz_Click(object sender, EventArgs e)
        {
            String constr = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=C:\\Documents and Settings\\Zohaib\\My Documents\\Visual Studio 2010\\Projects\\CheckAbility\\Qusetions.accdb";
            OleDbConnection conn = new OleDbConnection(constr);
            conn.Open();
            OleDbCommand command = new OleDbCommand("SELECT * FROM Table1", conn);
            OleDbDataReader recordset = command.ExecuteReader();
            label3.Text = recordset[0].ToString();
        }

there is only one record in my table
but its giving me error

no data exist for the row column

Also tell me how to select one record from the table on the basis of id????
Plz rply soon
Thanx in Advance

You need to invoke Read method.

OleDbDataReader recordset = command.ExecuteReader();
if(recordset.Read())
  label3.Text = recordset[0].ToString();
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.