private void btnSearch_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 code, product, stocks from searching where code='" + code.Text + "'";
SqlCommand sqlCmd = new SqlCommand(commandString, sqlCon);
SqlDataReader read = sqlCmd.ExecuteReader();
while (read.Read())
{
code.Text = read["code"].ToString();
product.Text = read["product"].ToString();
Stocks.Text = read["stocks"].ToString();
}
//problem start here
else
{
MessageBox.Show("Code not found. Thanx!");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
sqlCon.Close();
}