DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2006
    Posts
    100

    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

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    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!

  3. #3
    Join Date
    Feb 2006
    Posts
    55
    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
    David Wiseman
    MCSE (2000/2003), MCSA (2003), MCDBA
    www.wisesoft.co.uk


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

Bookmarks

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
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


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


Sponsored Links