Hallo everyone,
Iam using C# to insert a row into access table. Iam getting the values to insert from textbox. I got the error "cannot open action query". Here is my code
private void button1_Click(object sender, EventArgs e)
{
txt1 = textBox1.Text;
txt2 = textBox2.Text;
String connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Userinfo.accdb";
OleDbConnection connection = new OleDbConnection(connectionString);
OleDbDataAdapter adapter = new OleDbDataAdapter();
OleDbCommand command = new OleDbCommand();
// Create the InsertCommand.
command.CommandType = CommandType.Text;
command.CommandText = "INSERT INTO userinfo (Username, Pwd) VALUES (‘" + txt1 + "’ , ‘" + txt2 + "’)";
command.Connection = connection;
//command.Parameters.Add("txt1", OleDbType.Char, 5, "Username");
//command.Parameters.Add("txt2", OleDbType.VarChar, 10, "Pwd");
adapter.InsertCommand = command;
connection.Open();
command.ExecuteNonQuery();
connection.Close();
}
.
Any idea ?.
Thank you.
Dinesh.