| | |
Access database error "Cannot open action query"
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Nov 2008
Posts: 2
Reputation:
Solved Threads: 0
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
.
Any idea ?.
Thank you.
Dinesh.
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
C# Syntax (Toggle Plain Text)
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.
•
•
Join Date: Oct 2008
Posts: 32
Reputation:
Solved Threads: 4
Hi,
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);
connection.Open();
OleDbCommand command = new OleDbCommand("INSERT INTO userinfo (Username, Pwd) VALUES (‘" + txt1 + "’ , ‘" + txt2 + "’)";
command.ExecuteNonQuery();
connection.Close();
}
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);
connection.Open();
OleDbCommand command = new OleDbCommand("INSERT INTO userinfo (Username, Pwd) VALUES (‘" + txt1 + "’ , ‘" + txt2 + "’)";
command.ExecuteNonQuery();
connection.Close();
}
•
•
Join Date: Jul 2008
Posts: 66
Reputation:
Solved Threads: 6
hi
u need to specify proper database extension. i think here s the probelm ? u given so plz change to mdb this s ths access dbase extension and u have to use
chk it this and let me know
if ur problem solved plz mark as Solved
u need to specify proper database extension. i think here s the probelm ? u given
•
•
•
•
String connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Userinfo.accdb";
•
•
•
•
connection.open()
if ur problem solved plz mark as Solved
![]() |
Other Threads in the C# Forum
- Previous Thread: Dragging and dropping objects out of the windows forms.
- Next Thread: Connecting to database through programming
Views: 1356 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for C#
.net access ado.net algorithm array barchart bitmap box broadcast button c# check checkbox class client code color combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees development draganddrop drawing encryption event excel file files form format forms ftp function gdi+ http httpwebrequest image index input install java label list listbox listener login math mouseclick mysql networking object operator path photoshop picturebox pixelinversion post prime programming radians regex remote remoting resource save saving serialization server sleep socket sql statistics stream string table tcp text textbox thread time timer treeview update usercontrol validation view visualstudio webbrowser windows winforms wpf xml





