Hi,
i am having error in insert statement?.can you please rectify this problem.I am underlying the error.please find below.
Error:-There are more columns in the INSERT statement than values specified in the VALUES clause. The number of values in the VALUES clause must match the number of columns specified in the INSERT statement.
private void btn_submit_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("data source=mars-104;initial catalog=marsweb;integrated security=true");
SqlCommand cmd = new SqlCommand("insert into tbl_customer(custname,custaddress,custcity,custstate,custstdcode,custphoneno,custmobileno)values(@custname,@custaddress,@custcity,@custstate,@custstdcode,@custmobileno)", con);
cmd.Parameters.AddWithValue("@custname", txt_customername.Text);
cmd.Parameters.AddWithValue("@custaddress", txt_address.Text);
cmd.Parameters.AddWithValue("@custcity", txt_customercity.Text);
cmd.Parameters.AddWithValue("@custstate", txt_customerstate.Text);
cmd.Parameters.AddWithValue("@custstdcode", txt_stdcode.Text);
cmd.Parameters.AddWithValue("@custphoneno", txt_phoneno.Text);
cmd.Parameters.AddWithValue("@custmobileno", txt_mobileno.Text);
SqlDataAdapter da = new SqlDataAdapter(cmd);
con.Open();
cmd.ExecuteNonQuery(); MessageBox.Show("customer added successfully..");
con.Close();
txt_customername.Text = "";
txt_address.Text = "";
txt_customercity.Text = "";
txt_customerstate.Text = "";
txt_stdcode.Text = "";
txt_phoneno.Text = "";
txt_mobileno.Text = "";
}
Best,
Sudheep.