Identity using a recordset.AddNew method

Identity using a recordset.AddNew method

Post by Will Rickard » Sat, 01 Sep 2001 01:11:39



This method of inserting data is one of the slowest.
The schema information has to come to the client and then the update is sent to the server.
I would suggest reconsidering the use of an insert statement.  Perhaps you should consider
calling a stored procedure to insert the data.

SQL Server works quite a bit differently than access.
Try getting the identity value after the update.
http://support.microsoft.com/support/kb/articles/Q219/0/29.ASP

--
Will Rickards


> Hello
> I'm trying to add a new registry to a table that has one IDENTITY field.
> Using Access I can do:

>     rs.open "SELECT  Id, Name FROM Mytable WHERE Id=0", connection
>     rs.addNew
>     msgbox  rs.Id
>     rs.Name= "Lucas"
>     rs.Update
>     rs.close

> and it shows me the new IDENTITY value, and inserts the new registry.

> But in SQL SERVER it doesn't work!!!!!!
> The  rs.Id  field is an empty value !!!! Why??
> How can I obtain the new identity value, using this method (I don't want to
> create an INSERT statement) ??

> Thank you!