|
-
Feb 9th, 2005, 10:59 AM
#1
Thread Starter
Member
Returning @@Identity in VB6 ADO
I can't figure this one out, but this is basically what I have:
==================
Dim rsTemp As ADODB.Recordset
Set rsTemp = New ADODB.Recordset
With rsTemp
.CursorLocation = adUseClient
.CursorType = adOpenForwardOnly
.LockType = adLockReadOnly
.ActiveConnection = SQLConnectionString
End With
connMain.Open
Set rsTemp = connMain.Execute("SELECT @@Identity AS ClientID INSERT INTO Client (FirstName,LastName) VALUES ('Phil','McCrackin')")
connMain.Close
===================
The INSERT statement works, but rsTemp results with a Recordcount of -1 and its ClientID field is NULL. I've often had weird problems in ADO with recordsets having recordcounts of -1... but it was usually due to the cursor location/type. I've tried changing the cursor type, location, and locktype... but nothing. Maybe I just haven't hit the correct combination yet? *shrug* 
Any ideas? Or is there another/better way to return @@identity?
Thanks in advance!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|