7
Answers

How can I say "Code not found"?

Israel

Israel

10y
801
1
Hi!
 
How can I receive a message saying for example:  "Code not found. Thanx!"
See what I wrote and its doenst result:
 
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();
}
 
Answers (7)
0
Francis

Francis

NA 11.7k 724.1k 9y
Below post from Scott gu explains various ways to achive URL rewrite:
 
http://weblogs.asp.net/scottgu/tip-trick-url-rewriting-with-asp-net
 
Also below url gives a tutorial on URL rewrite:
 
http://www.c-sharpcorner.com/UploadFile/akkiraju/url-rewriting-in-Asp-Net/
 
Hope this helps!