MSDN Archive Home
Help and FAQs
Visual Basic Forms over Data Video Series Samples
All Resource Updates
Create New Discussion
adding new data to form having a GUID (unique identifier) column as primary key in VB 2005 Express / SQL 2005 Express (Video 2 connecting to the database) or how to set the default value of an Uniqueidentifier (or system.guid)?
Jan 27 2009 at 11:35 AM
First of all thank you very much for all the rich presentations and the ressources that you make available to ease our learning. All your materials are very helpful and very instructive.
I have followed step by step the video two (2connecting to database, mostly. I have reviewed all the other videos at least twice) to create a form for my table Area, which has a Code column as primary key, and datatype of uniqueidentifier, and other columns.
I have set the default value in SQL server for this column to Cast(Cast(Newid() as binary(10) + Cast (Getdate() as binary(6)) as uniqueidentifier)
The insertion of data via SQL Management sudio , and using the insert command of the Area dataset (that I have created for the in design mode) works just fine.
Now, when I tried to use the form on which I have dragged and dropped the Area dataset columns on it, The following occurs:
I can move back and forth on the row using the navigation tool strip generated and I can update and delete rows automatically and successfully, using the save and delete buttons.
.- But I have a problem adding new records in the Area table.
when I click on the (+) adding button, I experience the following errors:
First, when I click on add button, the (primary key) field code is empty. I was expecting a newly generated Code as I have successfully set the default value, and tested it in SQL server Management studio.
When I fill all fields and click on save,
I receive error stating that code column should not have DBNULL value.
I have checked the column Code attribute in the Area Dataset in design mode, and I have notice that the default value of Code is <DBNULL> and the datatype is system.guid.
I believe that my problem could be solve by properly setting the default value of the code column in Area dataset.
I am really stuck here for more than a week now as any work around attempt that I have undertaken is unfruitful.
So, I would gratefully accept your help or solution.
Please let me know if you need more information.
Please, accept my recognition once more for your quality work!
Sign in to post message or set email notifications
Manage Your Profile
MSDN Flash Newsletter
© 2008 Microsoft Corporation. All rights reserved.