I want to enter a value in a text box to add it in the database, but this value may be found already in the database
This code adds data from text box to the database, but without solving the problem of repetition of the same value that already exist in the database
private void button1_Click(object sender, EventArgs e)
{
da.InsertCommand = new SqlCommand("INSERT INTO MyTable VALUES(@Username,@Password)", sc);
da.InsertCommand.Parameters.Add("@Username", SqlDbType.VarChar).Value = textBox1.Text;
da.InsertCommand.Parameters.Add("@Password", SqlDbType.VarChar).Value = textBox2.Text;
sc.Open();
da.InsertCommand.ExecuteNonQuery();
sc.Close();
}
Please help

New Topic/Question
Reply



MultiQuote




|