When using a Guid, why not use a numeric field (replicationID)? If you want to show 'P' in front of the Guid in your UI doesn't mean that you need to save it in the database
I'm not sure what the "P" is doing for you though. Once you prepend the "P" it's no longer a GUID and to use it as such you'll first need to strip the "P" off later anyway.
krishyy
Member
26 Points
76 Posts
creating guid when inserting data to the MS Access database
Feb 11, 2010 02:10 PM|LINK
Hello folks
I have one question here.I created a registration form using asp.net and c#.
when I entered all the fields in that form and hit the register button the data will be inserted in to the database table called xyz table
in that table I have an id field which is a text field in access database consists of guid starting with letter P
when I inserting the data from aspx form...the guid is not inserting into the table.
one of my datarecord in that table with the id field is like this.(.P11111111-1BBB-4444-A9D1-111111111111)
need to insert anoother record in that table that field must be generate with the ID starting with P..its an guid....
would any one help me with the creating guid in the aspx.cs page..??
krishyyy
hans_v
All-Star
35998 Points
6551 Posts
Re: creating guid when inserting data to the MS Access database
Feb 11, 2010 03:36 PM|LINK
When using a Guid, why not use a numeric field (replicationID)? If you want to show 'P' in front of the Guid in your UI doesn't mean that you need to save it in the database
Anyway, to answer your question:
Guid NewId = Guid.NewGuid();
jwhipkey
Member
42 Points
13 Posts
Re: creating guid when inserting data to the MS Access database
Feb 11, 2010 03:46 PM|LINK
Does your cs code use...
String strGUID = System.Guid.NewGuid.ToString;
to generate your GUIDs?
krishyy
Member
26 Points
76 Posts
Re: creating guid when inserting data to the MS Access database
Feb 11, 2010 04:30 PM|LINK
guid gid = new guid();
gid = "P" + gid;
is this possible in my cs code?
krishyy
Member
26 Points
76 Posts
Re: creating guid when inserting data to the MS Access database
Feb 11, 2010 04:33 PM|LINK
String strGUID = System.Guid.NewGuid.ToString();
strGUID = "P" + strGUID;
Is This possible?
krishyy
Member
26 Points
76 Posts
Re: creating guid when inserting data to the MS Access database
Feb 11, 2010 04:41 PM|LINK
String strGUID = System.Guid.NewGuid().ToString();
strGUID = "P" + strGUID;
I tried this but not working.....the field ID in my table is not generating any value..like guid
jwhipkey
Member
42 Points
13 Posts
Re: creating guid when inserting data to the MS Access database
Feb 11, 2010 04:41 PM|LINK
Sure. or...
String strGuid = "P" + System.Guid.NewGuid.toString();
jwhipkey
Member
42 Points
13 Posts
Re: creating guid when inserting data to the MS Access database
Feb 11, 2010 04:45 PM|LINK
I'm not sure what the "P" is doing for you though. Once you prepend the "P" it's no longer a GUID and to use it as such you'll first need to strip the "P" off later anyway.
krishyy
Member
26 Points
76 Posts
Re: creating guid when inserting data to the MS Access database
Feb 11, 2010 04:51 PM|LINK
I did without P but its not working
Is there any other code...to add in my cs code....to generate guid...
jwhipkey
Member
42 Points
13 Posts
Re: creating guid when inserting data to the MS Access database
Feb 11, 2010 06:16 PM|LINK