here is my code.
protected void Button3_Click(object sender, EventArgs e)
{
SqlDataAdapter da;
string qry = "select * from salesmans_master where rankuser=" + salesuserid.Text;
da = new SqlDataAdapter(qry, con);
con.Open();
DataSet ds = new DataSet();
da.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
Label15.Text = "this salesid is already present.";
}
else
{
SqlCommand cmd = new SqlCommand("insert into salesmans_master(name,addressof,rankuser,rankcode)values('" + salesname.Text + "','" + salesadderss.Text + "','" + salesuserid.Text + "','" + DropDownList1.SelectedValue + "')", con);
try
{
con.Open();
cmd.ExecuteNonQuery();
Label15.Text = "data Inserted";
con.Close();
}
catch (Exception ex)
{
Label15.Text = ex.Message;
}
}