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
    Jun 2003
    Provided Answers: 1
    What is [FamilyID]? Why are you concatenating it?
    Better yet, why don't you just write this as a sproc, like it should be? Avoid dynamic SQL and direct queries of database tables. They are difficult to debug, inefficient, and fragile.
    If it's not practically useful, then it's practically useless.

    blindman "sqlblindman"

Posting Permissions

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