Write to access DB ASP need help

General software, Operating Systems, and Programming discussion.
Everything from software questions, OSes, simple HTML to scripting languages, Perl, PHP, Python, MySQL, VB, C++ etc.
Post Reply
kuleszajmk

Write to access DB ASP need help

Post 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
cyberskye
Senior Member
Posts: 4717
Joined: Wed Jan 10, 2001 12:00 am
Location: DC

Post 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.
anything is possible - nothing is free

:wth:
Blisster wrote:It *would* be brokeback bay if I in fact went and hung out with Skye and co (did I mention he is teh hotness?)
:wth:
rogue313
New Member
Posts: 6
Joined: Thu Apr 13, 2006 9:21 am
Location: Ontario, Canada

Post 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.
Rogue313
... old phone guy ...
Post Reply