G
Guest
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?
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?