Hi,
I'm wondering how to retrieve the primary key (an autonumber) from a
table immediately after a new record has been inserted. I'm using VB
6.0 / ADO / SQL Server 2000.
Cheers,
Mike.
I'm wondering how to retrieve the primary key (an autonumber) from a
table immediately after a new record has been inserted. I'm using VB
6.0 / ADO / SQL Server 2000.
Cheers,
Mike.
Does anybody ever search Google first? I entered the subject line of this post and got this.
Chris.
Hi,
I'm wondering how to retrieve the primary key (an autonumber) from a
table immediately after a new record has been inserted. I'm using VB
6.0 / ADO / SQL Server 2000.
Cheers,
Mike.
Mike,Quote:> Hi,
> I'm wondering how to retrieve the primary key (an autonumber) from a
> table immediately after a new record has been inserted. I'm using VB
> 6.0 / ADO / SQL Server 2000.
> Cheers,
> Mike.
using your connection object, cnn:
Set rst = cnn.Execute(sSQL, , adCmdText).NextRecordset
then retrieve the primary key using
lNewID = rst(0).Value
before closing the recordset, rst.
HTH
John Lee
On Thu, 6 Mar 2003 08:58:57 -0000, "Chris Barber"
>Does anybody ever search Google first? I entered the subject line of this post and got this.
>Chris.
>Hi,
>I'm wondering how to retrieve the primary key (an autonumber) from a
>table immediately after a new record has been inserted. I'm using VB
>6.0 / ADO / SQL Server 2000.
>Cheers,
>Mike.
I often find myself just posting the top couple of relevant (I check them out obviously) Google responses since
something that's already been thought about and presented on the web can often be better than my trying to explain
something.
Just so happens I had the same issue as this thread myself a couple of months back :)
Then again, if everyone did that (checked Google) then there would be no group - LoL!
Chris.
Chris,
Just thought you would like to know your note made a difference. I had
a query question and before posting I did exactly what you
said...Googled the heading as I would have sent it...guess
what...found the answer...WONDERFUL LIFE!!
John Lee
On Thu, 6 Mar 2003 08:58:57 -0000, "Chris Barber"
>Does anybody ever search Google first? I entered the subject line of this post and got this.
>Chris.
>Hi,
>I'm wondering how to retrieve the primary key (an autonumber) from a
>table immediately after a new record has been inserted. I'm using VB
>6.0 / ADO / SQL Server 2000.
>Cheers,
>Mike.
1. Primary Key / Working Code to get primary key of a table using ADO and schemas
2. Help Needed
3. Help using OPENXML to retrieve specific elements for use in SQL insert (SQL*Server 2000)
5. Retrieving data from Exchange 2000 server using ado/ado.net
6. use of NULL indicator for Insert
7. Retrieving XML from SQL Server 2000 using an ado connection object
8. BO And MS SQL Server, parameter for ANSI join syntax ? Is Anyone using MSSQL Server ?
9. SQL Server 2000 Trigger causes insert to fail on following insert statements
10. OO4O and VB6 - Retrieve primary key on insert
11. Retrieving primary key automatically generated in DB when inserting (in a CMP entity bean)
12. using big primary keys v/s small primary keys
13. How to use multiple Primary keys with SQL Server 2000