private void t=TextBox1_Leave(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("Data Source=localhost;Initial Catalog=DATABASE;Integrated Security=True");
SqlCommand comm = new SqlCommand();
comm.Connection = conn;
conn.Open();
comm.CommandText = "Select * From TABLE WHERE ID=@ID";
comm.Parameters.AddWithValue("@ID", TextBox1.Text);
SqlDataReader dr = comm.ExecuteReader();
if (dr.Read() == true)
{
MESSAGEBOX.SHOW("شماره وارد شده تكراري است");
}
}