Flash Games
 FAQ   Search   Memberlist   Usergroups   Register  Profile   Log in to check your private messages   Log in 


[Microsoft][ODBC Microsoft Access Driver]Invalid bookmark



 

Post new topic   Reply to topic  
   DEVPPL Forum Index -> ASP & ASP.NET Forum
View previous topic :: View next topic  
Author Message
gillivt



Joined: 27 Sep 2006
Posts: 1

PostPosted: Tue Oct 24, 2006 4:10 pm    Post subject: [Microsoft][ODBC Microsoft Access Driver]Invalid bookmark Reply with quote

I am writing to two tables which need to keep referential integrity.

When the tables are empty the code functions correctly and writes out to the sales table. It then retrieves the Autonumber Primary key so that it can be used to write sales line items to the second table.

The second time the code is executed I get an Invalid bookmark error.

The code follows:

'Create a database connection
set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open ConnectionString

'
'Open Recordset for sales
'
set rsSale = Server.CreateObject("ADODB.Recordset")
set rsLine = Server.CreateObject("ADODB.Recordset")

strSQL = "SELECT tblSales.chrMobile, " & _
"tblSales.chrPaymentMethod, " & _
"tblSales.idsInvoiceNumber " & _
"FROM tblSales;"

rsSale.CursorType = adOpenKeyset
rsSale.LockType = adLockOptimistic
rsSale.Open strSQL, adoCon
rsSale.Addnew

'write mobile number (users account number) & paymentmethod
rsSale.Fields("chrMobile") = Session("Mobile")
rsSale.Fields("chrPaymentMethod") = strPaymentMethod
rsSale.Update
Freeze = rsSale.Bookmark ' First, store the location of you cursor
rsSale.Requery ' Next, update your recordset with the data from the database
rsSale.Bookmark = Freeze ' Restore cursor (This is where the error occurs)
strInvoiceNumber = rsSale("idsInvoiceNumber") 'Get the just written autonumber
rsSale.Close

strSQL = "SELECT tblSalesLineItems.chrProductID, " & _
"tblSalesLineItems.intQuantity, " & _
"tblSalesLineItems.lngzInvoiceNumber, " & _
"tblSalesLineItems.lngzLineNumber " & _
"FROM tblSalesLineItems;"

rsLine.CursorType = adOpenDynamic
rsLine.LockType = adLockOptimistic
rsLine.Open strSQL, adoCon


'write the line items
intItems = 0
For Each strProductID in dictCart
intItems = intItems + 1
rsLine.AddNew
rsLine.Fields("chrProductID") = strProductID
rsLine.Fields("intQuantity") = dictCart(strProductID)
rsLine.Fields("lngzInvoiceNumber") = strInvoiceNumber
rsLine.Fields("lngzLineNumber") = intItems
rsLine.Update
Next

'Close recordSet
set rsLine = Nothing
set rsSale = Nothing
set adocon = Nothing


Can Anyone see what;'s going wrong?
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    DEVPPL Forum Index -> ASP & ASP.NET Forum All times are GMT + 1 Hour
Page 1 of 1

 
 
Welcome to DEVPPL.com
You are not logged in, which means that you can't post in the forums.
Click here to Register

If you are a current member here on DEVPPL, please login below:

User: Pass:
Log me on automatically each visit:

 


Powered by phpBB © 2001, 2005 phpBB Group - Modified by DEVPPL

Flash Games - Sitemap