There is the following code to insert a new record in the database:
System.Data.SqlClient.SqlConnection sqlConnection1 = new System.Data.SqlClient.SqlConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:/BD.mdb"); System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = "INSERT ThemeTest (Id_theme, NameTheme, NumberQuestion, Prim) VALUES"+ "(@Id_theme , @NameTheme, @NumberQuestion, @Prim)"; cmd.Connection = sqlConnection1; cmd.Parameters.AddWithValue("@Id_theme", 5); cmd.Parameters.AddWithValue("@NameTheme", textBox1.Text); cmd.Parameters.AddWithValue("@NumberQuestion", numericUpDown1.Value); cmd.Parameters.AddWithValue("@Prim", textBox2.Text); sqlConnection1.Open(); cmd.ExecuteNonQuery(); sqlConnection1.Close();
Swears on the connection string: "The keyword is not supported by provide". What am I doing wrong? How to write the connection string to the local table for access?