Click here to Skip to main content
15,888,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SqlCommand cmd = new SqlCommand("insert into Register values (@Username,@Password,@conformmail,@Repeatmail,@Dateofbirth,@Gender,@Mobile,@Address,@Selectcountry,@Selectstate,@Selectcity,@securityquestion,@Capchaimage)", con);
cmd.Parameters.AddWithValue("@Username",TextBox1.Text.ToString());
cmd.Parameters.AddWithValue("@Password", TextBox2.Text.ToString());
cmd.Parameters.AddWithValue("@ConformMail", TextBox3.Text.ToString());
cmd.Parameters.AddWithValue("@Repeatmail", TextBox4.Text.ToString());
cmd.Parameters.AddWithValue("@Gender", RdoGender.SelectedItem.Text.ToString());
cmd.Parameters.AddWithValue("@Dateofbirth",TextBox5.Text.ToString());
cmd.Parameters.AddWithValue("@Address", TextBox6.Text.ToString());
cmd.Parameters.AddWithValue("@Mobile", TextBox7.Text.ToString());
cmd.Parameters.AddWithValue("@Selectcountry", DropDownList1.Text.ToString());
cmd.Parameters.AddWithValue("@Selectstate", DropDownList2.Text.ToString());
cmd.Parameters.AddWithValue("@Selectcity", DropDownList3.Text.ToString());
cmd.Parameters.AddWithValue("@Capchaimage", TextBox8.Text.ToString());
cmd.Parameters.AddWithValue("@securityquestion", TextBox9.Text.ToString());
con.Open();
cmd.ExecuteNonQuery();
Response.Write("registered successfully");
con.Close();
Posted
Comments
Ashi0891 14-Aug-14 7:03am    
check for column names and number of columns in your table and also the order of columns that you are providing.
also you used @confirmmail in query and @ConfirmMail while passing parameters. it is case sensitive please use any one and only one of them at both places.
of all try executing this query in sql server database.
until and unless we dnt know abt your database and the table structure we cant answer such questions. try to explain what you post dnt simply copy paste your code here.

1 solution

Specify the column names in the query like

SQL
Insert into table1 (column1,column2) values (@value1,@value2);


The above exception will be resolved.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900