Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Data Binding / October 2006

Tip: Looking for answers? Try searching our database.

Default value of a GUID field?!

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Leon_Amirreza - 26 Oct 2006 06:58 GMT
I have a column named "ID" and its type is "uniqueidentifier" in SQL Server
2005 Express.
this column is the primary key and its default value is "newid()" in SQL
Server.

I have generated a DataSet in C# that has this column but its default value
is DBNull what can I do to make the default value be the return value of
this function ( or I want the Id be generated by default in the DataSet)?

System.Guid.NewGuid()
Bart Mermuys - 26 Oct 2006 21:45 GMT
Hi,

>I have a column named "ID" and its type is "uniqueidentifier" in SQL Server
>2005 Express.
[quoted text clipped - 5 lines]
> value of this function ( or I want the Id be generated by default in the
> DataSet)?

If you are using VB/VC#2005 then attach an eventhandler to
DataTable.TableNewRow to set a Guid.NewGuid.

HTH,
Greetings

> System.Guid.NewGuid()
Leon_Amirreza - 29 Oct 2006 09:12 GMT
I have attached this handler but when the user goes to the last (empty) row
of the grid and then leaves this fake data row an error is reported and
DataGrid does detect that the user hasnt entered any value and the row
should be dissmissed!?

how to correct this problem?

> Hi,
>
[quoted text clipped - 15 lines]
>
>> System.Guid.NewGuid()
Bart Mermuys - 29 Oct 2006 12:07 GMT
Hi,

>I have attached this handler

How did you implement the handler ?

> but when the user goes to the last (empty) row of the grid and then leaves
> this fake data row an error is reported and DataGrid does detect that the
> user hasnt entered any value and the row should be dissmissed!?

If the user enters the empty row and then leaves without entering any data
then the row should be dismissed and attaching an eventhandler to
TableNewRow for setting a new guid doesn't seem to prevent this.

And are you using a DataGrid or DataGridView ?

HTH,
greetings

> how to correct this problem?
>
[quoted text clipped - 17 lines]
>>
>>> System.Guid.NewGuid()
Leon_Amirreza - 30 Oct 2006 15:03 GMT
the function implementation is this:

void TableGroups_TableNewRow(object sender, DataTableNewRowEventArgs e)

{

(e.Row as DataSetGroups.TableGroupsRow).ID = Guid.NewGuid();

}

> Hi,
>
[quoted text clipped - 36 lines]
>>>
>>>> System.Guid.NewGuid()
Bart Mermuys - 30 Oct 2006 18:01 GMT
Hi,

> the function implementation is this:
>
[quoted text clipped - 5 lines]
>
> }

Looks ok to me, you're saying that this code is causing the problems with
the DGV ?

Greetings

>> Hi,
>>
[quoted text clipped - 36 lines]
>>>>
>>>>> System.Guid.NewGuid()

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.