4
Reply

warning message (code not find)

Mfwamba Tshimanga

Mfwamba Tshimanga

Jul 5 2014 6:12 AM
675
Hello!
 
My codes are working well without problem. What I need? I would like to have a warning message when the code was not find. Where can I put it and how to write thse codes. 
 
 
private void btnfindcod_Click(object sender, EventArgs e)
{
string connectionString = @"Data Source=localhost\sqlexpress;Initial Catalog=master;Integrated Security=True";
SqlConnection sqlCon = new SqlConnection(connectionString);
sqlCon.Open();
string commandString = "select * from company where code ='" + txtcode.Text + "'";
SqlCommand sqlCmd = new SqlCommand(commandString, sqlCon);
SqlDataReader read = sqlCmd.ExecuteReader();
while (read.Read())
{
txtprodut.Text = read["product"].ToString(); 
}
 
// It's probably here or not? ... code not found...
sqlCon.Close();
}
 

Answers (4)