i have error with ExecuteNonQuery pls help

  • Thread starter Thread starter jama0123456789
  • Start date Start date
J

jama0123456789

Guest
private void button1_Click(object sender, EventArgs e)
{
if (textusername.Text == "" || textpaaword.Text == "")
MessageBox.Show("please fill mandatory fiels");
else if (textpaaword.Text != textconfirmpassword.Text)
MessageBox.Show("password do not match");
else
using (SqlConnection sqlcon = new SqlConnection(connectionString))
{
sqlcon.Open();
SqlCommand sqlcmd = new SqlCommand("useradd", sqlcon);
sqlcmd.CommandType = CommandType.StoredProcedure;
sqlcmd.Parameters.AddWithValue("@firstname", textfirstname.Text.Trim());
sqlcmd.Parameters.AddWithValue("@lastname", textlastname.Text.Trim());
sqlcmd.Parameters.AddWithValue("@passportnumber", textpassportnumber.Text.Trim());
sqlcmd.Parameters.AddWithValue("@contactnumber", textcontactnumber.Text.Trim());
sqlcmd.Parameters.AddWithValue("@address", textaddress.Text.Trim());
sqlcmd.Parameters.AddWithValue("@UserName", textusername.Text.Trim());
sqlcmd.Parameters.AddWithValue("@password", textpaaword.Text.Trim());
sqlcmd.ExecuteNonQuery();
MessageBox.Show("Registration is successfull");
clear();
}

}
void clear()
{
textfirstname.Text = textlastname.Text = textpassportnumber.Text = textcontactnumber.Text = textaddress.Text = textusername.Text = textpaaword.Text =textconfirmpassword.Text = "";
}

Continue reading...
 
Back
Top