By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,722 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

Reusing @Identity values

P: n/a
Hi

im still hving a problem with my Identity value that is returned after my insert query

What i have done is inserted a row into a datatable and then used an dataAdapters UPDATE command to push the values into my database
My insert query looks like the following..

ALTER PROCEDURE dbo.InsClientAndSelIdentit

@Surname char(50)
@Forename char(50)
@OrgName varchar(50)
@Address varchar(300)
@Postcode varchar(50)
@PhoneNo varchar(25)
@Identity int OU

A
SET NOCOUNT OFF
INSERT INTO Client(Surname, Forename, OrgName, Address, Postcode, PhoneNo) VALUES (@Surname, @Forename, @OrgName, @Address, @Postcode, @PhoneNo)
SET @Identity = SCOPE_IDENTITY()
Retur

I then assign the returned @Identity value to the datatable the values were pushed from
by using..

Dim myIdentity As SqlParameter = daClient.InsertCommand.Parameters.Add("@Identity", SqlDbType.Int, 0, "ClientID"

The problem is that this puts the value back into the parent table that the UPDATE method was run on. I want to add this value to another child table instead
Is there anyway i can place this returned IDENTITY value into a variable so it can be reused elsewhere??

As im running really short on time, any help would be fantastic
Deadlines :o

Jul 21 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.