L
Larry B via DotNetMonster.com
Hello,
I seem to be having a problem with inserting data, from a web form, into an
access database. I have tried
to do the same thing in a regular windows app, there it works fine, but when
I try to do the same thing in an ASP. NET form I get an error saying the
'query needs to be updateable'. The code is identical, except for a little
difference in the connection string.
Here is my code in the web form, from a button click handler:
OleDbConnection DBConnection = new OleDbConnection("Provider=Microsoft.JET.
OLEDB.4.0;Data Source=" + this.Server.MapPath("JobRegistry.mdb") + ";");
OleDbCommand cmd = new OleDbCommand("INSERT INTO Jobs (job_id, job_name,
job_num, div_id, builder, location) VALUES ('0000-000', 'test1', '3999', '2',
'OK', 'OKLOCATION')", DBConnection);
cmd.Connection.Open();
cmd.ExecuteNonQuery();
cmd.Connection.Close();
This generates the error message I receive:
'Operation must use an updateable query'
This is the same code used in the windows app, from a button click handler:
OleDbConnection DBConnection = new OleDbConnection("Provider=Microsoft.JET.
OLEDB.4.0;DataSource=JobRegistry.mdb");
OleDbCommand cmd = new OleDbCommand("INSERT INTO Jobs (job_id, job_name,
job_num, div_id, builder, location) VALUES ('0000-000', 'test1', '3999', '2',
'OK', 'OKLOCATION')", DBConnection);
cmd.Connection.Open();
cmd.ExecuteNonQuery();
cmd.Connection.Close();
This works fine.
Seems I am missing missing something somewhere. This is basically my first
attempt at working with a database source using ASP.NET and a web form. Any
help would be appreciated!
Thank You
Larry Burnett
I seem to be having a problem with inserting data, from a web form, into an
access database. I have tried
to do the same thing in a regular windows app, there it works fine, but when
I try to do the same thing in an ASP. NET form I get an error saying the
'query needs to be updateable'. The code is identical, except for a little
difference in the connection string.
Here is my code in the web form, from a button click handler:
OleDbConnection DBConnection = new OleDbConnection("Provider=Microsoft.JET.
OLEDB.4.0;Data Source=" + this.Server.MapPath("JobRegistry.mdb") + ";");
OleDbCommand cmd = new OleDbCommand("INSERT INTO Jobs (job_id, job_name,
job_num, div_id, builder, location) VALUES ('0000-000', 'test1', '3999', '2',
'OK', 'OKLOCATION')", DBConnection);
cmd.Connection.Open();
cmd.ExecuteNonQuery();
cmd.Connection.Close();
This generates the error message I receive:
'Operation must use an updateable query'
This is the same code used in the windows app, from a button click handler:
OleDbConnection DBConnection = new OleDbConnection("Provider=Microsoft.JET.
OLEDB.4.0;DataSource=JobRegistry.mdb");
OleDbCommand cmd = new OleDbCommand("INSERT INTO Jobs (job_id, job_name,
job_num, div_id, builder, location) VALUES ('0000-000', 'test1', '3999', '2',
'OK', 'OKLOCATION')", DBConnection);
cmd.Connection.Open();
cmd.ExecuteNonQuery();
cmd.Connection.Close();
This works fine.
Seems I am missing missing something somewhere. This is basically my first
attempt at working with a database source using ASP.NET and a web form. Any
help would be appreciated!
Thank You
Larry Burnett