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 + "'";

      sqlconn = new SqlConnection(connstr);
      sqlCmd = new SqlCommand(strSql, sqlconn);
     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();
Catch (Exception Ex)

Edited 6 Years Ago by LennieKuah: typo error

Hi Adatapost,
Thank you very much for sharing the information with me. I tried it out and it's working. You are awesome sharing information with me to help me.
This FORUM is awesome to have you .

Glad to meet you here.

Edited 6 Years Ago by LennieKuah: n/a

This question has already been answered. Start a new discussion instead.