SqlConnection conn = new SqlConnection(); conn.ConnectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=E:\project\Projects\secquestion and password change with new tarika insert\labelnameinsecondformtry\Database1.mdf;Integrated Security=True;User Instance=True"; SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; conn.Open(); try { cmd.CommandText = "INSERT INTO Table2 (username,password,sec_questions) VALUES (@username,@password,@sec_question)"; cmd.Parameters.Add("@username", SqlDbType.VarChar).Value =textBox1.Text; cmd.Parameters.Add("@password", SqlDbType.VarChar).Value = textBox2.Text; cmd.Parameters.Add("@sec_questions", SqlDbType.VarChar).Value =comboBox1.Text; cmd.ExecuteNonQuery();//error is coming which is "Must declare the scalar variable @sec_question." } finally { conn.Close(); MessageBox.Show("hello welcome"); }
cmd.Parameters.Add("@sec_questions", SqlDbType.VarChar).Value =comboBox1.Text;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)