Saturday, March 24, 2012

Operation must use updateable query

I am getting the error below when I try to insert some data from textboxes into a table in my database. I have checked the security permissions on the database file itself, IUSR_mypc and IWAM_mypc both have full permission. I have reset the permissions on the whole parent directory but no change. My code is after the error. The code used to work, I haven't made any changes to IIS at all so I'm confused why the error is occuring. :(

A problem has ocurred: System.Data.OleDb.OleDbException: Operation must use an updateable query. 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() at sticket1_aspx_vb.btnSubmitTicket_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\PROJECT\sticket.aspx.vb:line 19


Dim myConnection As Data.OleDb.OleDbConnection = New Data.OleDb.OleDbConnection
Dim fileNameString As String = Me.MapPath("support.mdb")
Dim ConStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & fileNameString
Dim SqlStr As String = "INSERT INTO Tickets (cno,eno,priority,submitTime,category,description,links,images,thisPC,active) VALUES('" & txtClientNumber.Text & " ','" & txtEngineerNumber.Text & "','" & ddlPriority.Text & "','" & theTime & "','" & DDLcategory.Text & "','" & txtDescription.Text & "','" & txtLink.Text & "','" & txtImageLink.Text & "','" & radioThisPC.Text & "','" & "True" & "')"

Dim Cmd As New Data.OleDb.OleDbCommand(SqlStr, myConnection)
myConnection.ConnectionString = ConStr

Try
myConnection.Open()
Cmd.ExecuteNonQuery()
Catch myException As Exception
lbl.Text = ("A problem has ocurred: " + myException.ToString())
Finally
myConnection.Close()
End TryHere are a few things to check...

http://support.microsoft.com/kb/q175168/

Also, are you trying to update linked tables to another source or are you updating native access tables?

Lastly, if you put a breakpoint after you set your commandtext copy and paste it into a query window in access and run the query by hand do you get the same error?
The command works fine when run manually in Access. I have even tried to just insert one field in the table but the same error occurs. They are native access tables.

I have spent hours on this but I'm not getting anywhere :(
Hmm well I recreated the Access database from scratch (luckily I didn't need any data it contained) and the error has gone. The security settings all look the same, I turned off inherited permissions to make sure. Nevermind it works now thats the main thing :)

The INSERT command works fine except when inserting boolean True/False values, which are the last 2 in the command called thisPC and active. An error complains of a datatype mismatch for them. In Access the datatypes are set to Yes/No with a format of True/False. The two values on runtime are set to True and are of type boolean. Whats the problem here? :sick:

Dim SqlStr As String = "INSERT INTO Tickets (cno,eno,priority,submitTime,category,description,links,images,thisPC,active) VALUES('" & txtClientNumber.Text & "','" & txtEngineerNumber.Text & "','" & ddlPriority.Text & "','" & theTime & "','" & DDLcategory.Text & "','" & txtDescription.Text & "','" & txtLink.Text & "','" & txtImageLink.Text & "','" & thisPC & "','" & active & "')"
I think, (from memory here, I havn't tested it) that using a 1 and a 0 for true and for false will work with Access. I remember there being a disconnect between it and SQL or Oracle when it comes to boolean values.
Ah it works with 1's and 0's. Thanks very much scuzymoto! :thumb:

0 comments:

Post a Comment