i am inserting value from combobox but there is some error i am a newbie so dont know much about .net
here is my code
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();
}
finally
{
conn.Close();
MessageBox.Show("hello welcome");
}