If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > uniqueidentifier query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-15-10, 14:03
surajnshah surajnshah is offline
Registered User
 
Join Date: Apr 2010
Posts: 2
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:

Code:
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.
Reply With Quote
  #2 (permalink)  
Old 04-21-10, 07:56
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
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...
Code:
"SELECT [family_name] FROM tblFamily WHERE [family_id] = '" & UserID & "'"
P.S. don't forget about SQL injection and what not!
__________________
George
Twitter | Blog
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On