troubleshooting Question

Operation must use an updateable query.

Avatar of ba272
ba272 asked on
C#
10 Comments3 Solutions1138 ViewsLast Modified:
Hi,

I'm running into trouble using some trusted database code in a web service, where I get the exception "Operation must use an updateable query." when calling this line:

Connection conn = new OleDbConnection();
conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;" +
@"Data source=c:\\tmp\\MyDatabase.mdb";
conn.Open();

OleDbCommand dbInsertCommand = new OldDbComand();
dbInsertCommand.Connection = conn;

sql = "INSERT INTO GPSEvents
(DeviceID,DeviceDate,DeviceTime,ServerDate,ServerTime,Latitude,Longitude,NumDownloads) VALUES ('100','2/13/2006','21:09:10','2/13/2006','22:14:08','42.1234','-70.1234','0')";

dbInsertCommand.CommandText = sql;
dbInsertCommand.ExecuteNonQuery(); <<<<<<<<<<<< this line

The database connection seems to be fine, since the Open() function is working for my OleDbConnection.

Here's the exception:
Operation must use an updateable query. trace:  
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
   at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
   at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
   at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
   at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()

Does anyone have any idea what this could be?  This is a web service running the database code.  Are there any special considerations?

Thanks for the help.

Bob
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 3 Answers and 10 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 10 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros