[thelist] ASP: object read only?
Anthony Baratta
Anthony at Baratta.com
Fri Jul 11 15:56:20 CDT 2003
At 12:52 PM 7/11/2003, Casey Crookston wrote:
>Two questions.
>
>First, I'm trying to update a record in my db (Access) and it keeps telling
>me the object is read-only. I thought that by specifying adLockOptimistic I
>was making in not read only. What else do I need to do? (See entire code
>block below)
Make sure the web server has rewrite access to the directory AND the target
DB file.
>Second, I'm aware that this is the clumsy way to go about this process and I
>would much rather just update the record from the SQL statement, but I'm not
>sure of the VBScript syntax. Any suggestions? The query would look like
>this: "UPDATE texts SET block = '"&block&"' WHERE text_id="&text_id" but
>again it's the VBScript that I'm unsure of.
try this way:
<!-- #INCLUDE FILE="../adovbs.inc" -->
<%
Dim Connect, rcrdSet, Query, text_id, text, varStatus
text_id = trim(request("text_id"))
block = trim(request("block"))
Set Connect = Server.CreateObject("ADODB.Connection")
Connect.Open "boser_db"
Query = "Update texts Set block = '" & EscapeDBData(block) _
& "' WHERE text_id = " & EscapeDBData(text_id)
Connect.Execute Query,varStatus
Connect.Close
if varStatus = 1 then
'' successful update of record
elseif varStatus = 0 then
'' Failed to update record
else
'' Something went way wrong ;-P
end id
Function EscapeDBData(varDataLine)
if not(varDataLine = "") then
varDataLine = Replace(varDataLine,"'","''",1,-1,1)
end if
EscapeDBData = varDataLine
End Function
%>
---
Anthony Baratta
President
Keyboard Jockeys
"Conformity is the refuge of the unimaginative."
More information about the thelist
mailing list