VB.NET Retrieving Identity from MSSQL2000 without using stored procedures

T

Taras

Hello!
I have a problem. I'm using a dataset in VB.NET with multiple tables with
relations between them. I would like dataset to update to all related tables
with right identity, when certain record is added.

The problem is that I don't know how to do it, when I'm not using stored
procedures. I found an article in which OnRowUpdated event of the
dataadapter is used. On this event ExecuteScalar method of the oledbcommand
object is called to retrieve "@@Identity"

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
l/cpconretrievingidentityorautonumbervalues.asp

But this example was for Access 2000 database. I tried to translate it for
MSSQL 2000 but ExecuteScalar always returns
null.

In the same article there's an example which calls a stored procedure in a
insert command. In that case everything is working perfectly, all child
tables in dataset are automatically changed.

Does anybody have any idea how to solve this?

Regards, Taras
 
H

Herfried K. Wagner [MVP]

Hello,

Taras said:
I have a problem. I'm using a dataset in VB.NET with multiple
tables with relations between them. I would like dataset to
update to all related tables with right identity, when certain record
is added.

This is a VB.NET language group. Notice that you will have a better
chance to get an answer if you post to the ADO.NET newsgroup in future:

news://msnews.microsoft.com/microsoft.public.dotnet.framework.adonet

Web interface:

http://msdn.microsoft.com/newsgroup...roup=microsoft.public.dotnet.framework.adonet
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top