PDA

View Full Version : Can't update


tomei
05-22-2003, 06:37 AM
Hi,

I'm current using MySQL and ASP.

But there seems to be a problem when i try to update a particular record. I get the following error message.

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
Query-based update failed because the row to update could not be found.

Set rs = Server.CreateObject("ADODB.Recordset")
sql = "SELECT * FROM MainPageContents " & _
"WHERE BelongsToShop=" & Session("ShopID") & _
" AND ID=" & which

rs.Open sql, conn, adOpenKeyset, adLockOptimistic

rs.update
rs("some_fld") = "something"
rs.update

I tried setting cursor locations to aduseclient and aduseserver but to no avail. There's also nothing wrong with the query. Does anyone know if there's any kind of issue on updating MySQL using ASP? and is there any solution for this problem?

Thanks

raf
05-22-2003, 05:44 PM
Can't you just use an updatestatement instead of creating and editing a recordset? Like

dim sql, numupdated
sql = "UPDATE MainPageContents SET some_fld="something" WHERE BelongsToShop=" & Session("ShopID") & " AND ID=" & which
conn.Execute sql,numupdated

if numupdated > 1 then
code if update whas succesful
else
code if update was not succesfull
end if


about you error. Are you sure there are any records selected? If you copyed your code correct, then i think there is an error in you where clause (before the 'and')

tomei
05-23-2003, 02:21 AM
I can use an UPDATE statement, but I've a reason for doing that...

I'm 100% positive that theres nothing wrong with the query. But thanks anyway.