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
The sample code is in C#, but you should get the idea.
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
Hope this helps,
Last Post: 05-12-2005, 09:35 AM
By Jane Felluer in forum .NET
Last Post: 05-23-2002, 05:44 AM
By Aditya in forum Database
Last Post: 04-29-2002, 08:39 AM
By Warren Dyer in forum Database
Last Post: 03-05-2002, 02:54 PM
By asger in forum Database
Last Post: 11-20-2000, 12:59 PM
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