Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB6 / SQL newid() command problem

Status
Not open for further replies.

mrrrl

MIS
Dec 26, 2001
179
US
Having problems working with uniqueindentifiers(guid), MS SQL V7 and VB6.

I need to insert a guid into an existing sql database. The field is the DB is setup for guids. How do you use the newid() to generate a guid and then insert it into the database?


TIA

 

Since the NEWID() is a SQL function and not a VB function you'll have to use it as part of your SQL statement.

NewID() can be used with an INSERT statement to generate an id for the uniqueidentifier data type column in your table:

strSQL = "INSERT INTO table(column, guid) " & _
"SELECT 'columndata', NEWID()"




Mark

"You guys pair up in groups of three, then line up in a circle."
- Bill Peterson, a Florida State football coach
 
Thanks, I must have been really tired yesterday. I thought I had tried that, but I guess not.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top