Web Design and Development Forums

Get value from SQL string ?

This is a discussion on "Get value from SQL string ?" within the ASP Forum section. This forum, and the thread "Get value from SQL string ? are both part of the Program Your Website category.


Go Back   Webforumz.com > Program Your Website > ASP Forum

Welcome to Webforumz.com.
Register Now Register now!

Reply
 
LinkBack Thread Tools Rate Thread
Old Jan 27th, 2008, 21:49   #1 (permalink)
New Member
 
Join Date: Dec 2007
Location: Los Angeles
Posts: 4
Get value from SQL string ?

Hi all,
I am trying to get the value from a SQL string and store it in a variable but i'm guessing DLookup is not used in VBScript/ASP as it is with Access/VBA which is my background so the synax below is of course not working !

HTML: Select all
strvalue = dlookup("PicInsert") FROM tblCon WHERE "Name" = Request.Form("contributor")
How would I go about doing this ?
Thanks in advance,
Mitch...

Last edited by Monie; Jan 28th, 2008 at 00:34. Reason: adding the [html] tag for asp code...
VegaLA is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Jan 28th, 2008, 01:06   #2 (permalink)
Most Reputable Member
 
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,567
Blog Entries: 2
Send a message via Yahoo to Monie
Re: Get value from SQL string ?

You are right about "DLookup is not used in VBScript/ASP"!
But there is a VBScript Function that you could use, It imitates the functionality of the MS Access function of the same name which is like the one that you are using ^

Code: Select all
strvalue = dlookup("PicInsert") FROM tblCon WHERE "Name" = Request.Form("contributor")
I am not sure that you use the correct syntax for your code above ^ but from what I understand when I see your code is that you are trying to retrieve the PicInsert field from the tblCon table where the Name is from your contributor input field. This is the same as the following SQL statement in more organize and fast way:

HTML: Select all
<%
   Dim strvalue, name
   name = Request.Form("contributor")
   strvalue  = ("SELECT PicInsrt FROM tblConn WHERE Name= '"& name &"'")
%>
Note: when retrieving a string value, you must put ' around them. " is for numbers. Assign any value that you would like to search into a variable for fast script execution (Like what I have done with your Request.Form)
__________________


Last edited by Monie; Jan 28th, 2008 at 01:08.
Monie is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Jan 29th, 2008, 13:40   #3 (permalink)
Up'n'Coming Member
 
Join Date: Sep 2007
Location: Wales, UK
Age: 35
Posts: 75
Send a message via MSN to robbied72 Send a message via Skype™ to robbied72
Re: Get value from SQL string ?

The only Comment I will make to Monie's code is not to use reserved names like "name" but rather use something like "vName", I always use v's in front of variables to clearly denote them.

Have a look at this page for a list of reserved names - http://www.webthang.co.uk/tuts/tuts_...rds/rwords.asp

Hope this helps.
__________________
Languages: ASP, RUBY(a little), XML, XHTML, CSS, JavaScript, JQuery - www.bizmo.co.uk
robbied72 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Jan 29th, 2008, 23:53   #4 (permalink)
Most Reputable Member
 
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,567
Blog Entries: 2
Send a message via Yahoo to Monie
Re: Get value from SQL string ?

Thanks for the tips robbied!
So the code should look like this:
HTML: Select all
<%
  Dim strvalue, vName
  vName = Request.Form("contributor")
  strvalue  = "SELECT PicInsrt FROM tblConn WHERE Name= '"& vName &"'"
%>
and you should consider changing your database field name as well, "Name"!
__________________


Last edited by Monie; Jan 30th, 2008 at 07:36.
Monie is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Jan 30th, 2008, 07:13   #5 (permalink)
Up'n'Coming Member
 
Join Date: Sep 2007
Location: Wales, UK
Age: 35
Posts: 75
Send a message via MSN to robbied72 Send a message via Skype™ to robbied72
Re: Get value from SQL string ?

Kind of, I would also rename the database field "Name" to UserName or something as it is also a reserved name.
__________________
Languages: ASP, RUBY(a little), XML, XHTML, CSS, JavaScript, JQuery - www.bizmo.co.uk
robbied72 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Jan 30th, 2008, 07:39   #6 (permalink)
Most Reputable Member
 
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,567
Blog Entries: 2
Send a message via Yahoo to Monie
Re: Get value from SQL string ?

Yeah... that sort that out!
Instead of using VBScript function, you should consider just stick with simple SQL statement to do just what you wanted for faster script execution.
__________________

Monie is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
special effect string? spandro JavaScript Forum 1 Nov 8th, 2006 09:53
string capacity Don Logan JavaScript Forum 11 Sep 23rd, 2006 20:28
append % to the string chandra.nowduri ASP.NET Forum 1 Aug 9th, 2006 09:47
Connection String DSN-less gwx03 ASP Forum 11 Nov 26th, 2003 12:07
dns less connection String djaccess ASP Forum 7 Oct 5th, 2003 14:34



Latest Updates

All Points SEO Security Advisory - CHECK YOUR SITE NOW!

Creative Coding :: February 2008

Webforumz is sponsored by: WESH UK Web Hosting
All times are GMT. The time now is 20:06.

Sleep Study Scoring :: Free Bet :: Website Templates :: Online Betting :: Bookmakers :: Funny Quotes :: Internet Recruitment Software :: Microsoft CRM Experts :: Online Casino :: Decorated Christmas Trees :: Midwife Forums :: Football Betting :: Ecommerce Software :: Web Hosting :: Football Stats :: Dry Cleaning Collection :: xtreme wales - extreme clothing :: Apuestas :: Sharepoint Consultants :: Website Optimisation :: Office Clearance London :: Sharepoint Experts :: Sports Betting :: Casino :: Website Templates :: Web Design Development India :: Online Gambling

Powered by: vBulletin Version 3.7, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
© 2003-2008 Webforumz.com : All Rights Reserved
Search Engine Friendly URLs by vBSEO 3.2.0 RC6


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59