Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I have a sort of admin area for a f

Status
Not open for further replies.

adamsoderqvist

Programmer
Sep 8, 2001
136
SE
I have a sort of admin area for a forum. The admin is supposed to be able to update former messages in the DB (Access, BTW). It works allright, BUT for some reason some posts wont (while some works perfectly! This is the err-msg I get:

"Microsoft OLE DB Provider for ODBC Drivers error '80004005'

Query-based update failed because the row to update could not be found."

Now, the row is there but still the message!

This is the code used:

'Declare recordset object...
Dim objRS
Set objRS = Server.CreateObject("ADODB.Recordset")

Dim strSQL
strSQL = "SELECT * FROM tblForum WHERE ForumID=" &
Request.QueryString("PostID")

'Open the database and get the requested info!
objRS.Open strSQL, objConn, , adLockOptimistic

'Declare var's for message info...
strMessage = Request("NewMsg")

'..and update the database!
objRS("Message") = strMessage
objRS.Update

Does anyone know?

//thanx
 
It looks like your Request.QueryString("PostID") is missing on not a valid ForumID (considering you do not realy have a crlf after the following text: WHERE ForumID=" &)
You can use Request("PostID") as long as the PostID is a uniqe name because if you leave out the QueryString or Form it wil just take the first item with the name PostID.
Can you change your code a little like the code below:


'Declare recordset object...
Dim objRS
Set objRS = Server.CreateObject("ADODB.Recordset")

Dim strSQL
strSQL = "SELECT * FROM tblForum WHERE ForumID=" &
Request.QueryString("PostID")

'Open the database and get the requested info!
objRS.Open strSQL, objConn, , adLockOptimistic

'Declare var's for message info...
strMessage = Request("NewMsg")

if rs.bof and rs.eof then 'check if the query returned a record
'oops, no record in the recordset. dump the query string and see what is wrong.
response.write strsql
else
'..and update the database!
objRS("Message") = strMessage
objRS.Update
end if
 
thanx, but I don´t really get the issue. What´s the problem with my code, and what should I do about it...?
 
Like before:
It looks like your Request.QueryString("PostID") is missing on not a valid ForumID
That means you have to check the page before thisone and see why the postid is wrong or missing

And the line:
if rs.bof and rs.eof then 'check if the query returned a record
'oops, no record in the recordset. dump the query string and see what

Checks if there are any records in the recordset, if not the sql string is put on the screen so you can see what the postid was (if it was provided).
You could try to go to the first record before inserting a new value in message.
objRS.MoveFirst
objRS("Message") = strMessage
objRS.Update
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top