Re: Checking for return codes

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Sahil Malik (contactmethrumyblog_at_nospam.com)
Date: 05/26/04


Date: Wed, 26 May 2004 12:13:26 -0400

Hmm .. @@IDENTITY?

That is assuming I understood your question correctly LOL.

The last generated key in a SQL Server can be found by calling "Select
@@IDENTITY"

However here is another idea that you might find useful -

Once you fill your dataset, you could set the seed and increment of your
dataset to -1, so there are never any collisions when you finally go
inserting new rows. So in the method in which you finally update the
database, you could then refill your dataset replacing the -1's with the
actual keys that the SQL Server generated. I can't wait till Yukon where my
stored proc. will accept a dataset rather than me trying to mangle it to a
REF CURSOR or equivalent.

Wish I knew more to answer you better :), but hope this helps.

- Sahil Malik
Independent Consultant
You can reach me thru my blog - http://dotnetjunkies.com/WebLog/sahilmalik/

"Gary" <anonymous@discussions.microsoft.com> wrote in message
news:B9D6E006-9ECF-4E3E-A4FE-06F3EBEF6906@microsoft.com...
> I am using the update method of a dataadapter to insert a record into a
table in SQL Server from a VB .Net procedure. The data adapter is calling a
stored procedure. In the stored procedure I would like to run a select to
verify that the record does not already exist in the table, since the key
field is an autoincremented key. How do I pass back the return code from the
select in the SQL Server stored procedure to my VB .Net procedure? Thanks.



Relevant Pages

  • Re: How to get list of EventClasses in MSSQLServer2000
    ... statement inside a stored procedure has completed.') ... SQL Server statement or stored procedure.') ... Plan','Displays the plan tree of the Transact-SQL statement executed.') ... Login','Occurs when a SQL Server login is added or removed; ...
    (microsoft.public.sqlserver.security)
  • Re: Accessing FoxPro Free Table
    ... which the SQL Server service is running. ... account, ... > If you are creating a stored procedure and you want> to make sure that the procedure definition cannot be> viewed by other users, you can use the WITH ENCRYPTION> clause. ... The procedure definition is then stored in an> unreadable form. ...
    (microsoft.public.data.odbc)
  • Re: Adding date to parameter
    ... SqlClient provider which is specifically written for SQL Server. ... Hitchhiker's Guide to Visual Studio and SQL Server ... and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook) ... I made the assumption that the stored procedure went by the ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Problem with the Legacy ASP files and the Sql Server Express
    ... table, if another inserting occurs at the nearly exactly the same moment, ... SQL Server will pass it a default value. ... assume that you do have a connection that can reach SQL Server Express. ... unless your stored procedure has some thing that only works ...
    (microsoft.public.dotnet.framework.aspnet)
  • Stored procedure does not complete until result set is retrieved from ODBC
    ... I have a SQL Server Stored procedure that I am executing via ODBC. ... -- Start Code without cursor ...
    (microsoft.public.sqlserver.odbc)