RE: GUIDs & uniqueidentifiers in datasets
From: Cowboy (Gregory A. Beamer) - MVP (NoSpamMgbworld_at_comcast.netNoSpamM)
Date: 11/08/04
- Next message: Cowboy (Gregory A. Beamer) - MVP: "RE: Timeout error from SqlDataReader even when ConnectionTimeout = 0"
- Previous message: Stewart Saathoff: "Manipulate Dataset at Runtime"
- In reply to: James Coates: "GUIDs & uniqueidentifiers in datasets"
- Next in thread: James Coates: "RE: GUIDs & uniqueidentifiers in datasets"
- Reply: James Coates: "RE: GUIDs & uniqueidentifiers in datasets"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 8 Nov 2004 09:30:02 -0800
You can generate a new GUID in your code using the System.Guid structure.
This GUID will still be globally unique, even though it is not created in the
database.
---
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
***************************
Think Outside the Box!
***************************
"James Coates" wrote:
> I am developing a windows forms application which takes its data from an SQL
> server database where all the primary keys are uniqueidentifier fields.
>
> I am creating strongly typed datasets and populating them using the Fill
> method. My problem is how to generate guids when inserting rows into the
> datasets, for example when the dataset is bound to a datagrid control. Can
> this be done?
>
> I have also tried using the AddRow method as below:
>
> Dim drNewRow As DsProductRange.CategoriesRow =
> dsProductRange1.Categories.NewCategoriesRow
>
> drNewRow.CategoryID.NewGuid()
> drNewRow.CategoryName = "New Range"
> dsProductRange1.Categories.AddCategoriesRow(drNewRow)
>
> However the .NewGuid() method here doesn't seem to work as the CategoryID
> field has already picked up a {System.InvalidCastException} error (I think
> related to the way the field is described in the generate XSD schema. Is
> there anyway to generate guid values as default values to the dataset field
> like calling the newid() function in the SQL table?
> --
> James Coates
> York, England
- Next message: Cowboy (Gregory A. Beamer) - MVP: "RE: Timeout error from SqlDataReader even when ConnectionTimeout = 0"
- Previous message: Stewart Saathoff: "Manipulate Dataset at Runtime"
- In reply to: James Coates: "GUIDs & uniqueidentifiers in datasets"
- Next in thread: James Coates: "RE: GUIDs & uniqueidentifiers in datasets"
- Reply: James Coates: "RE: GUIDs & uniqueidentifiers in datasets"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|