0
protected void Button3_Click(object sender, EventArgs e)
{
{
if (TexBo_num.Text == "" && TexBo_num.Text != "contact_no")
{
ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Either contact_number is empty or Wrong');", true);
}else
{
SqlConnection con = new SqlConnection(@"Data Source=SYSTEM2\SQLEXPRESS;Initial Catalog=amresh;Integrated Security=True");
con.Open();
SqlDataAdapter value = new SqlDataAdapter("Select * FROM detail WHERE contact_no ="+TexBo_num.Text, con);
DataSet val = new DataSet();
value.Fill(val);
if ((val.Tables[0].Rows[0]["contact_no"]).ToString() == TexBo_num.Text)
{
SqlDataAdapter da = new SqlDataAdapter("select name,address from detail where contact_no =" + TexBo_num.Text, con);
DataSet ds = new DataSet();
da.Fill(ds);
string nam = ds.Tables[0].Rows[0]["name"].ToString();
string add = ds.Tables[0].Rows[0]["address"].ToString();
TxtBox_name.Text = nam;
TexBo_add.Text = add;
}else
{
ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('value not found');", true);
}
con.Close();
}
}
必須調試:) –