Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2010

    Unanswered: uniqueidentifier query

    hi there. i need some help with a query please. my table has two fields:

    family_id {identity} - uniqueidentifier

    family_name - nvarchar

    I have a query in my ASP.NET code (in VB.NET) that should compare a family_id as supplied by the user as a string with the family_id in the table and output the corresponding family_name.

    My query is as follows:

    Dim UserID As String = New String(Membership.GetUser(User.Identity.Name).ProviderUserKey.ToString())
    Dim queryString As String = "SELECT [family_name] FROM tblFamily WHERE ' & [family_id] & ' = ' & UserID & ' ;"
    The problem is, that whenever I execute this, it never returns anything.

    Thanks in advance for any help you can give me.

  2. #2
    Join Date
    Jan 2007
    Provided Answers: 12
    The issue is your SQL statement - try printing it to screen to see it's value prior to execution.

    What you want should be something closer to this...
    "SELECT [family_name] FROM tblFamily WHERE [family_id] = '" & UserID & "'"
    P.S. don't forget about SQL injection and what not!
    Home | Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts