Re: How To Return Record Number From AddNew



On 27/08/2007 in message <ecOJhlJ6HHA.5160@xxxxxxxxxxxxxxxxxxxx> Bob Barrows [MVP] wrote:

My pesonal recommendation: don't use a recordset for data maintenance. Instead, use SQL DML (INSERT, UPDATE and DELETE) statements, wither encapsulated in saved parameter queries (stored procedures) or parameterized with parameter markers. This will allow you to execute the SELECT @@identity statement to retrieve the new autonumber.

Many thanks, Bob :-)
The links are particularly helpful, and they led to other links and so on...

I am struggling to find which version of MSJet I have. There are jet500.dll, msjet35.dll and msjet40.dll on the system. I use Access 97 and the connections string is:

strConnection = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=";
strConnection += m_DBPath;
strConnection += ";";

Since this works then presumably I have version 4?

I am trying to add "SELECT @@IDENTITY" to the connection string but it falls over with that.

My real problem at the moment is:

If I use adRS("0") I get the error 'adRS' is a 'variable' but is used like a 'method'
If I use adRS["RecordNumber"] I get the error Cannot apply indexing with [] to an expression of type 'ADODB.Recordset'

All the examples I have found are VB/VBScript, usually you can replace round brackets with square ones for C but apparently not here!

Can you give me any more pointers?
I am happy to research/experiment but would like to avoid blind alleys.

Thanks again.

--
Jeff Gaines
.