View Single Post
  #2 (permalink)  
Old February 20th, 2004, 12:36 PM
DaveGerard DaveGerard is offline
Friend of Wrox
 
Join Date: Sep 2003
Location: Minneapolis, MN, USA.
Posts: 171
Thanks: 0
Thanked 1 Time in 1 Post
Default

Try this...

ProductId = request("ProductId")
Desc=request("Name")
Category = request("Category")
ShortDesc=request("Short_Detail")
DetailDesc=request("DetailDescription")

cn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=F:\Projects\MyProject\Database\MyProject.md b;"

set rs = server.createobject("adodb.recordset")
sql = "select * from Product where idProduct = '" & ProductId & "'"
rs.open sql, cn, 3, 3
if rs.eof then
    rs.addnew
    rs("idProduct")
end if
    rs("Description") = Desc
    rs("Category") = Category
    rs("ShortDetails") = ShortDesc
    rs("DetailedDescription") = DetailDesc
    rs.update

This code will add the ProductId if it doesn't exist and modify it if it does. This is also provided that your ProductId is an alpha-numeric value rather than a number. If your ProductId is a number then you must not have it enclosed within apostrophes. Forget the function 'getfromdatabase()'. Make sure your memo field is last in the update. Not sure if it matters with an update, but it does matter when you include memo fields within your criteria so it might apply here too. Let me know if this helps.

Dave

Reply With Quote