'dr' denotes a 'variable' where a 'method' was expected

  • Thread starter Thread starter Dan
  • Start date Start date
D

Dan

I am going through a tutorial, and as far as I can see, have made no typing
errors,
However, the below code gives me the error message:
Any ideas???

private void btnStart_Click(object sender, System.EventArgs e)

{

System.Data.OleDb.OleDbDataReader dr;

oleDbConnection1.Open();

dr = oleDbCommand1.ExecuteReader();



while (dr.Read())

{

txtResults.Text += dr("CUSTOMER");

dr.Close();

oleDbConnection1.Close();

}

}
 
Thank you , That did it.
Looks like I found the right group to help learn c sharp!

Stelrad Doulton said:
change

txtResults.Text += dr("CUSTOMER");

to

txtResults.Text += dr["CUSTOMER"];

Dan said:
I am going through a tutorial, and as far as I can see, have made no
typing errors,
However, the below code gives me the error message:

Any ideas???

private void btnStart_Click(object sender, System.EventArgs e)

{

System.Data.OleDb.OleDbDataReader dr;

oleDbConnection1.Open();

dr = oleDbCommand1.ExecuteReader();



while (dr.Read())

{

txtResults.Text += dr("CUSTOMER");

dr.Close();

oleDbConnection1.Close();

}

}
 
Back
Top