It's a runtime exception when I try to insert to a table, it was working before I added an update function.
private void button1_Click(object sender, EventArgs e)
{
Random rndID = new Random();
int id = rndID.Next(100, 1000);
SqlConnection connection = new SqlConnection(@"Data Source=DESKTOP-IOHHC7K\SQLEXPRESS;Initial Catalog=CityAppDB;Integrated Security=True");
SqlCommand command = new SqlCommand("insert into UsersTB(User_ID, Full_Name, Email_Address, Phone_Number, Password)
values('" + id.ToString() + "','" + textBox2.Text + "','" +
textBox3.Text + "','" + textBox4.Text + "','" +
textBox5.Text + "')", connection);
command.Connection.Open();
if ((ISExisted(id)) && (CheckUserFullName(textBox2.Text)) && (IsValidEmail(textBox3.Text)) && (IsValidPhoneNumber(textBox4.Text)) && (IsValidPassword(textBox5.Text)))
{
command.ExecuteNonQuery();//String or binary data would be truncated
MessageBox.Show("Added.");
ShowAllUsers();
}
else
{
MessageBox.Show("Something wrong");
}
command.Connection.Close();
}