-
SQL GUID in vb.net problem
I have an insert query that will input some new document information and will be assigned (by SQL server) a GUID for each one. Well I have to referance these with another table. The problem is I have no idea how to get the id or handle it with vb.net? Anyone have experiance with this? I am using a tableadapter in VS 2005 and I have seen tell about the @@identity but I can't seem to figure out how to get it to work right. Any idea guys?
Thanks in advance
Jackie
-
http://davidhayden.com/blog/dave/arc...2/16/2803.aspx
The sample code is in C#, but you should get the idea.
Phil Weber
http://www.philweber.com
Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
-
Note - It's quite safe to generate GUID's from the client - It's not safe to generate identities from the client though. With identities you need to use @@Identity, SCOPE_IDENTITY() or IDENT_CURRENT() - SCOPE_IDENTITY() is the safest method to return the id created by your insert statement. These methods are not for GUIDs.
If you are using uniqueidendifier/GUID you can generate these from the client in VB.NET and specify them in the insert statement - you generate guids using the following code:
Dim myGuid As Guid = Guid.NewGuid
MessageBox.Show(myGuid.ToString)
Hope this helps,
David
Similar Threads
-
Replies: 9
Last Post: 05-12-2005, 08:35 AM
-
By Jane Felluer in forum .NET
Replies: 6
Last Post: 05-23-2002, 04:44 AM
-
By Aditya in forum Database
Replies: 0
Last Post: 04-29-2002, 07:39 AM
-
By Warren Dyer in forum Database
Replies: 0
Last Post: 03-05-2002, 01:54 PM
-
By asger in forum Database
Replies: 3
Last Post: 11-20-2000, 11:59 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks