Well, it won't work, unless your customer id is "CUST_NAME".
Try this:
CON.Open();
SqlCommand CMD = new SqlCommand("SELECT CUST_NAME FROM CUSTOMER WHERE CUST_ID=@ID", CON);
CMD.Parameters.AddWithValue("@ID", myCustomerIDThatIAmLookingFor);
SqlDataReader DR = CMD.ExecuteReader();
if (DR.Read())
{
CUST_NAME.Text = DR["CUST_NAME"].ToString();
}
CON.Close();
Note that I also changed your
while
loop to an
if
- since you overwrite the text in the box each time a loop is probably not what you want...