ADO / SQLDataAdapter Question

  • Thread starter Thread starter Doug
  • Start date Start date
D

Doug

Hi,

I have a quick question -

I have a table where the primary key is an autogenerated GUID via SQL Server
2k. The table has just 2 fields, the PK and the ChangeDate. When I do an
insert into the table w/ the date, the PK is generated, but I need to have
that PK value returned to the application for use elsewhere. Is there a way
to have this value returned to my application w/o having a routine that goes
back and gets it? I thought there was something, but I can't remember it.
Thanks.

Doug
 
Well, there are a couple of ways to approach this

1. If using an sp to do the insert simply use the newid function (which is
probably the default on that particular column) explicitly within the sp and
return as a single row/column recordset or an output parameter.

2. Generate the GUID in your code via System.Guid.NewGuid() and pass it to
the db for insertion as a parameter.

HTH
Chris Torgerson
 
Chris,

Thanks...not using SP's using DataSets. Don't want to generate a GUID if
SQL can do it for me, i don't want to manage RI. I did figure out a
solution though that was steering me in the face. Thanks.

Doug
 
Back
Top