Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 .Get A Value

Author  Topic 

sirmilt
Starting Member

49 Posts

Posted - 2010-11-22 : 17:22:33
I am working with SQL Server express 2008 And visual Basic 2008. Here's what I'm trying to do, if it is possible.

Using an Insert query to create a new record in the table. A sequential ID number is inserted when the quey is run in Visual Basic.

I want to capture this number in a variable and use it immediately following the execution of the query.

Is this possible or do I have to capture the value in a second query?

Milt

X002548
Not Just a Number

15586 Posts

Posted - 2010-11-22 : 17:50:39
you should use stored procedures, and if it's possible, you need to grape the scope_identity() value after the insert



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-11-24 : 09:40:26
see

http://www.a1vbcode.com/vbtip-118.asp

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -