Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hey -

 

I am trying to create a GUID in VB.NET. What is the code for this? Is it

 Dim newGUID as New GUID() 

Also, how can I insert this value into an SQL table?

 

Thanks

Thanks,

Tehon

  • *Experts*
Posted

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

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
  • *Experts*
Posted

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

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Posted

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

Thanks,

Tehon

  • Leaders
Posted
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:

Dim g As Guid
       g = System.Guid.NewGuid

--tim
Posted
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.

Thanks,

Tehon

  • Leaders
Posted

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.

--tim
Posted

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

Thanks,

Tehon

  • Leaders
Posted
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.
--tim
Posted
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??

Thanks,

Tehon

  • Leaders
Posted

I'd want to know more about the data but generally...

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.

--tim

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...