Page 1 of 1

Write to access DB ASP need help

Posted: Sat Feb 18, 2006 1:30 pm
by kuleszajmk
Hi all
The following works for delet but not for write.
I changed err to error seemed to help but still does not write.?


<%on error resume next
set conn=Server.CreateObject("ADODB.Connection")
conn.provider="Microsoft.Jet.OLEDB.4.0"
conn.open(server.mappath("/fpdb/dbtest.mdb"))

if Request.form("action")="Save" then
ID=Request.Form("ID")
sql="UPDATE tblmaster SET Master_number='" & Request.Form("Master_number") & "',"
sql=sql & "Netdropship_item_no='" & Request.Form("Netdropship_item_no") & "',"
sql=sql & "mega_item_no='" & Request.Form("mega_item_no") & "',"
sql=sql & "sku='" & Request.Form("sku") & "',"
sql=sql & "amt='" & Request.Form("amt") & "',"
sql=sql & "international='" & Request.Form("international") & "',"
sql=sql & "EST_AVAIL='" & Request.Form("EST_AVAIL") & "' WHERE tblmaster.[ID]=" & ID
conn.Execute sql, Recordsaffected

if error <> 0 then
Response.Write("You do not have permission to update this database!")
else
Response.Write("Record number " & ID & " was updated.")
end if

end if
if Request.Form("action")="Delete" then
ID=Request.Form("ID")
conn.Execute "DELETE FROM tblmaster WHERE tblmaster.[ID]=" & ID, Recordsaffected
if error <> 0 then
Response.Write("You do not have permission to delete a record from this database!")
else
Response.Write("Record number " & ID & " was deleted.")
end if
Response.Write("Deleting records has been disabled from this demo")
end if

conn.close%>


Thanks
James

Posted: Tue Feb 21, 2006 11:26 pm
by cyberskye
Don't know ASP but my guess would be the precedence of " and ' characters. That seems to be the key difference between your UPDATE and DELETE functions.

Posted: Thu Apr 13, 2006 10:49 am
by rogue313
I have to admit that I do not know ASP either (just starting to delve into it), but, I would suggest from prior experience that you may want to recheck two things:
1 - the number of double and single quotes being used in the *save* section.
2 - the order and format of the *sql =* syntax, between the *ID=Request.Form("ID")* and the first *if error <> 0 then* statement in the same *save* section.

It just seems that there is something a bit out of place there.