p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Classic ASP Databases (http://p2p.wrox.com/forumdisplay.php?f=62)
-   -   Modifying long text in a long field (http://p2p.wrox.com/showthread.php?t=9496)

sajsal February 18th, 2004 03:25 AM

Modifying long text in a long field
 
Hi All

I am developing a website using asp and access. I have some pages in which user can type very long text in a textarea and submit it. The long text is saved in a memo field. When text is small (e.g. 1000 characters), it is saved (as well modified) successfully. But when I try to submit very long data (e.g. 4000 characters), it generates following error:

[Microsoft][ODBC Microsoft Access Driver] Could not save; currently locked by user 'admin' on machine 'ABC'.

and the error number is 2147467259.

My code is:

ProductID = request("Product ID")

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

mySQl= "select * from Product where idProduct='"&ProductID&"'"
call getfromdatabase(mySQL, rsModifyProduct ,"EditProduct")

rsModifyProduct("Description")=Desc
rsModifyProduct("Category")=Category
rsModifyProduct("ShortDetails")=ShortDesc
rsModifyProduct("DetailedDescription"=DetailDesc 'Memo Field

rsModifyProduct.update


*******************************
Database Manupulation Functions
*******************************

sub openDb()
if varType(connTemp)=0 or varType(connTemp)=1 then

  ' create the connection
  set connTemp = server.createObject("adodb.connection")

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

end if
end sub


sub getFromDatabase(mySQL, rstemp, scriptName)

  call openDb()

  set rstemp = server.createObject("adodb.recordset")

  rstemp.open mySQL,connTemp,3,2

end sub

sub updateDatabase(mySQL, rstemp, scriptName)

call openDb()

set rstemp=connTemp.execute(mySQL)

end sub

DaveGerard February 20th, 2004 12:36 PM

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



All times are GMT -4. The time now is 01:17 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.