SQL GUID in vb.net problem

DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: SQL GUID in vb.net problem

  1. #1
    Join Date
    Mar 2006

    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

  2. #2
    Join Date
    Nov 2003
    Portland, OR

    The sample code is in C#, but you should get the idea.
    Phil Weber

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Feb 2006
    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,

    David Wiseman
    MCSE (2000/2003), MCSA (2003), MCDBA

Similar Threads

  1. vb.net to sql server
    By pantea in forum .NET
    Replies: 9
    Last Post: 05-12-2005, 08:35 AM
  2. how to convert ms access sql to vb.net sql
    By Jane Felluer in forum .NET
    Replies: 6
    Last Post: 05-23-2002, 04:44 AM
  3. Replies: 0
    Last Post: 04-29-2002, 07:39 AM
  4. SQL Server Memory Problem I think?
    By Warren Dyer in forum Database
    Replies: 0
    Last Post: 03-05-2002, 01:54 PM
  5. SQL / IIS problem...help
    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
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center