If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Retrieving the new record ID (MYSQL - ASP)

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-06-03, 17:26
nmd nmd is offline
Registered User
 
Join Date: Feb 2003
Posts: 15
Unhappy Retrieving the new record ID (MYSQL - ASP)

Can any help with this little problem I'm generally used to working with ASP/SQLServer but need to use MYSQL this time.

When I insert a new record I use the following method to retrieve the auto increment ID of that row.

strSQL = Mytable
strDB = My Database connection string

Set rsData = Server.CreateObject("ADODB.Recordset")
RSData.CursorLocation = 3 ' adUseClient
RSData.Open strTable, strDB, adOpenKeySet, adLockOptimistic, adCmdTable

RSData.addNew

RSData("Company_Name") = "My new company"

RSData.Update

strNewCompany_ID = RSData("Company_ID")
strNewCompany_Name = RSData("Company_Name")

RSData.Close
Set RSData = Nothing

This method works fine with SQLServer but with MySQL it just retrieves the ID and Company name of the first row in the database.

The new record is inserted fine - the db might be used by a high number of users so I don't just get the MAX ID number after a new insert.

Thanks
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On