| | |
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: 65
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
| Thread Tools | Search this Thread |
.net access algorithm alignment app array barchart bitmap box broadcast c# c#gridviewcolumn cast check checkbox client combobox communication control conversion csharp custom database datagrid datagridview dataset datatable datetime degrees development draganddrop drawing elevated encryption enum excel file focus form format forms function gdi+ hospitalmanagementsystem httpwebrequest image index input install java label list listbox localization login mandelbrot math messagebox mouseclick mysql operator path photoshop picturebox pixelinversion plotting pointer post programming radians read regex remote remoting richtextbox server sleep socket sql statistics stream string stringformatting sun table text textbox thread time timer update usercontrol validation visualstudio webbrowser whileloop windows winforms wpf xml





