If you are executing a SQL command that returns a result, such as executing a SELECT statement you will have to use a different method. The SqlCommand's ExecuteReader method returns a SqlDataReader object that contains all of the records retrieved after executing the SQL command
.
try
{
SqlDataReader dr;
dbCon.Open();
//write your select statement here.....
dr = sqlcom.ExecuteReader();
if(dr.HasRows == True)
{
txt_clientID.Text = ((Integer) dr["cID"]).ToString();
txt_clientAddress.Text = (String) dr["cAddress"];
txt_clientPhoneNumber.Text = (String) dr["cPhoneNumber"];
}
dr.Close();
dbCon.Close();
}
catch(Exception ex)
{}