Hi All,
I'm looking for some information/code samples on how I can create a
simple web form that includes an auto-generated Unique ID on the form.
The form includes the following 3 fields (Unique ID, First Name and
Last Name). I have a SQL Server 2000 back-end with the table created
as follows:
UniqueID - numeric (9)
FirstName - varchar (50)
LastName - varchar (50)
Ideally I would like the user just to enter their First and Last Name
and the form automatically creates a Unique ID for them. Once they
type in their First/Last Name the user submits the information to the
database. I've managed to get the web form created so that it submits
the First/Last Name successfully but I can't think how to create the
Unique ID, ideally I'd like this to be based around the time/date of
submittal.
Any guidance would be much appreciated.
Thanks
ScottJames... If you declare an IDENTITY column, SQL will return a
uniqueID upon INSERT. If you want to generate your own
uniqueID you could do a concatenation of the MAC address of the
client ethernet card plus a timestamp.
Regards,
Jeff
>I've managed to get the web form created so that it submits
the First/Last Name successfully but I can't think how to create the
Unique ID, ideally I'd like this to be based around the time/date of
submittal.<
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Using a system generated GUID is quick and easy, although kinda long.
16 bytes minimum.
"James Brown" <i.m@.winning.com> wrote in message
news:1f88a50b.0307051028.3caafaf1@.posting.google.c om...
> Hi All,
> I'm looking for some information/code samples on how I can create a
> simple web form that includes an auto-generated Unique ID on the form.
> The form includes the following 3 fields (Unique ID, First Name and
> Last Name). I have a SQL Server 2000 back-end with the table created
> as follows:
> UniqueID - numeric (9)
> FirstName - varchar (50)
> LastName - varchar (50)
> Ideally I would like the user just to enter their First and Last Name
> and the form automatically creates a Unique ID for them. Once they
> type in their First/Last Name the user submits the information to the
> database. I've managed to get the web form created so that it submits
> the First/Last Name successfully but I can't think how to create the
> Unique ID, ideally I'd like this to be based around the time/date of
> submittal.
> Any guidance would be much appreciated.
> Thanks
> Scott
Showing posts with label unique. Show all posts
Showing posts with label unique. Show all posts
Saturday, March 31, 2012
Submitting form with a unique ID
Monday, March 26, 2012
Suggestion for generating unique identifier.
Anyone have any suggestions for generating a unique identifier for a DB
column. I don't want to use an IDENTITY column because two seperate tables
will have PK columns that cannot have duplicate key values amongst the
tables. I thought about something to do with Date/Time. It can be any
datatype for that matter, it does not have to be an int type. I just need
something to uniquely identify records from two seperate tables.
Thanks
Marty UMarty U. <Marty U.@.discussions.microsoft.com> typed:
> Anyone have any suggestions for generating a unique identifier for a
> DB column. I don't want to use an IDENTITY column because two
> seperate tables will have PK columns that cannot have duplicate key
> values amongst the tables. I thought about something to do with
> Date/Time. It can be any datatype for that matter, it does not have
> to be an int type. I just need something to uniquely identify records
> from two seperate tables.
> Thanks
> Marty U
You could use a GUID. In C#:
string myGuid = Guid.NewGuid().ToString();
Davide Vernole
MVP ASP/ASP.NET
Microsoft Certified Solution Developer
GUID
SQL Server datatype "uniqueidentifier"
Greg
"Marty U." <Marty U.@.discussions.microsoft.com> wrote in message
news:D6C67BD9-3AA6-4125-9F4D-E16C63E94A89@.microsoft.com...
> Anyone have any suggestions for generating a unique identifier for a DB
> column. I don't want to use an IDENTITY column because two seperate tables
> will have PK columns that cannot have duplicate key values amongst the
> tables. I thought about something to do with Date/Time. It can be any
> datatype for that matter, it does not have to be an int type. I just need
> something to uniquely identify records from two seperate tables.
> Thanks
> Marty U
Marty U. wrote:
> Anyone have any suggestions for generating a unique identifier for a DB
> column. I don't want to use an IDENTITY column because two seperate tables
> will have PK columns that cannot have duplicate key values amongst the
> tables. I thought about something to do with Date/Time. It can be any
> datatype for that matter, it does not have to be an int type. I just need
> something to uniquely identify records from two seperate tables.
>
GUIDs are often used for that:
Guid id = Guid.NewGuid();
this corresponds to SQL Server's UniqueIdentifier type.
The SQL server can generate one using the NEWID() function - you can set
the column's default value to NEWID() to have the GUID generated
automatically for new records.
mikeb
column. I don't want to use an IDENTITY column because two seperate tables
will have PK columns that cannot have duplicate key values amongst the
tables. I thought about something to do with Date/Time. It can be any
datatype for that matter, it does not have to be an int type. I just need
something to uniquely identify records from two seperate tables.
Thanks
Marty UMarty U. <Marty U.@.discussions.microsoft.com> typed:
> Anyone have any suggestions for generating a unique identifier for a
> DB column. I don't want to use an IDENTITY column because two
> seperate tables will have PK columns that cannot have duplicate key
> values amongst the tables. I thought about something to do with
> Date/Time. It can be any datatype for that matter, it does not have
> to be an int type. I just need something to uniquely identify records
> from two seperate tables.
> Thanks
> Marty U
You could use a GUID. In C#:
string myGuid = Guid.NewGuid().ToString();
Davide Vernole
MVP ASP/ASP.NET
Microsoft Certified Solution Developer
GUID
SQL Server datatype "uniqueidentifier"
Greg
"Marty U." <Marty U.@.discussions.microsoft.com> wrote in message
news:D6C67BD9-3AA6-4125-9F4D-E16C63E94A89@.microsoft.com...
> Anyone have any suggestions for generating a unique identifier for a DB
> column. I don't want to use an IDENTITY column because two seperate tables
> will have PK columns that cannot have duplicate key values amongst the
> tables. I thought about something to do with Date/Time. It can be any
> datatype for that matter, it does not have to be an int type. I just need
> something to uniquely identify records from two seperate tables.
> Thanks
> Marty U
Marty U. wrote:
> Anyone have any suggestions for generating a unique identifier for a DB
> column. I don't want to use an IDENTITY column because two seperate tables
> will have PK columns that cannot have duplicate key values amongst the
> tables. I thought about something to do with Date/Time. It can be any
> datatype for that matter, it does not have to be an int type. I just need
> something to uniquely identify records from two seperate tables.
>
GUIDs are often used for that:
Guid id = Guid.NewGuid();
this corresponds to SQL Server's UniqueIdentifier type.
The SQL server can generate one using the NEWID() function - you can set
the column's default value to NEWID() to have the GUID generated
automatically for new records.
mikeb
Labels:
asp,
column,
dbcolumn,
generating,
identifier,
identity,
net,
seperate,
unique
Subscribe to:
Posts (Atom)