Re: Adding rows to a dataset where the primary key is type System.Guid



Actually, there are a number of ways to do this. First, you can create your
own GUIDs with the Framework. NewID comes to mind.
Dim x As Guid
x = Guid.NewGuid

This can be done in the new row event or when building up the INSERT
statement. And yes, one approach I use it to create a block of rows in a SP
on the server and simply do UPDATES on the rows...

hth


--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------

"michael" <howlinghound@xxxxxxxxxxxxx> wrote in message
news:772FC597-BB47-4B16-AE5B-D415E3251CAD@xxxxxxxxxxxxxxxx
So, I'm working with VS 2005 (VB) and SQL Server(both 2000 and 2005). A
table
in the SQL Server db has a column, which is the primary key, of type
uniqueidentifier. The RowGuid attribute is "yes" and the default value is
newid().

In my application I have a dataset that has a table with the same schema
(actually I created a typed dataset which has the table). I wonder how to
approach adding new rows to the dataset and protect the integrity of this
primary key field:

1) Should I first insert a row to SQL Server and then read the row back
into
the dataset to get the value of the field as set by the newid() of
SQLServer
(is there an equivalent @@Identity?).

2) Is there an equivalent newid() in ADO.NET to create the guid within the
application and then insert the row into SQL Server?



--
Michael Hockstein


.



Relevant Pages