Hi Good Guys,
I encounter another interesting problem due to my lack of C# knowledge. Please Help me.
I am trying to use DATAREADER to fill TEXTBOX controls on the FORM and it's not working because this coding generate error message:
sqlDR = sqlCmd.ExecuteReader(); <---- Error
Error message:
Error 1 Cannot convert method group 'ExecuteReader' to non-delegate type 'System.Data.SqlClient.SqlDataReader'. Did you intend to invoke the method?
Here are the coding:
private SqlConnection sqlconn;
private SqlCommand sqlCmd;
private SqlDataAdapter sqlDA;
private SqlDataReader sqlDR;
private DataSet DS;
private void FDisplayCustomerDetails()
{
/* display customer details */
string strCustID = this.listBox1.SelectedValue.ToString();
string strSql = "Select * from Customers where CustomerId = '" + strCustID + "'";
try
{
sqlconn = new SqlConnection(connstr);
sqlCmd = new SqlCommand(strSql, sqlconn);
sqlconn.Open();
sqlDR = sqlCmd.ExecuteReader();<---- Error
// display customer details from SQLDR and not Orders
while (sqlDR.Read())
{
this.txtCustName.Text= sqlDR["CompanyName"].ToString();
this.txtAddr.Text = sqlDR["Address"].ToString();
}
sqlDR.Close();
}
Catch (Exception Ex)
{
MessageBox.Show(Ex.Message);
}
}