GUID's

tehon3299

Centurion
Joined
Jan 6, 2003
Messages
155
Location
Liverpool, NY
Hey -

I am trying to create a GUID in VB.NET. What is the code for this? Is it
Visual Basic:
 Dim newGUID as New GUID()
Also, how can I insert this value into an SQL table?

Thanks
 
Do you need the GUID client side or can you let SQL Server create it? I think it's something like this (might be off and I don't have SQL server here):

DECLARE @GUID AS uniqueidentifier
SELECT @GUID = new GUID

I don't know how to get one in VB.NET...

-nerseus
 
Do you HAVE to have it on the ASPX page? Normally it's a good idea to let SQL Server create the GUID if you're talking about inserting into a uniqueidentifier column. I've had to create them in VB6 because I needed the GUID to insert into multiple, joined tables.

If you just need a GUID for another reason and want to insert it into a table just for storage, then someone else will have to help.

-nerseus
 
What I need to do is:

-Create the GUID
-Insert it into an SQL table
-Create an SQL table and name it with the GUID

So this mean that I would need to create it on the ASPX page, right??

Thanks
 
tehon3299 said:
What I need to do is:

-Create an SQL table and name it with the GUID

I was tracking with you til you said this. If you're saying what I think you're saying this is *really* strange.

Either way it's:
System.Guid.NewGuid

As in:
Visual Basic:
Dim g As Guid
        g = System.Guid.NewGuid
 
Why is this *really* wierd? I want to be able to have user be able to create an account and have an individual table for each user. So when they create their account, they have a GUID associated with their Username and Password. Then I can load their table after they log in.
 
it's strange (and very wrong IMO) to create a whole new database table with identical data models on the fly for every user. ideally, your data model would not change once it's stable. i know of no dba that would let me assume this in my software design.

why not just create a tblAccounts that is in a one-to-many relationship with tblAccountDetails? That'd be a fairly standard approach to what it sounds like you're doing.
 
Well thank you for letting me know this. I am not aware of all the particulars when programming since I am a 19 year old college student just trying to learn Visual Basic and the .NET platform.

Thanks
 
fair enough. if you're interested post up a description of your problem and I'm sure folks here can help with a good database design that doesn't include dynamic creation of tables.
 
OK...Here's the idea. I need to have many people access this web application with different usernames and passwords. Each person is going to have specific data in their table. How would I go about designing this??
 
I'd want to know more about the data but generally...
Code:
create table tblUsers
(
   userID int,
   userName varchar(50),
   password varchar(24)
)
create table tblUserData
(
   id int,
   userID int,
   someData varchar(200),
   someData2 varchar(200),
   someData3 varchar(200),
   etc... (200),
)

to get data out for a particular user, use something like
SELECT * FROM tblUserData JOIN tblUsers on tblUsers.userID=tblUserData.userID where userName='quwiltw'

or, more likely you'll maintain the foreign key userID and will never actually need the join. Obviously, I've had to make a number of assumptions in my answer but hopefully it'll get you on a better path.
 
Back
Top