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 > Function that has sql statement

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-27-05, 08:26
gop373 gop373 is offline
Registered User
 
Join Date: Aug 2004
Posts: 77
Function that has sql statement

I am trying to write function which consists of sql statement. Is it possible to do that ? I tried this code but it did not work. Any suggestion !!!

<!--#include file="connect.asp"-->
<%
Function Test(strColumn,strTable,strCondition)
set rst=server.createobject("adodb.recordset")
rst.open sql,conn,1,3
sql="Select"&strColumn&"From"&strTable&"where"&str Condition
End Function

dim a
a=Test("price","BA","id="&1)
response.write a
%>
Reply With Quote
  #2 (permalink)  
Old 02-27-05, 17:00
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
well what you have won't work, but something close to it will, more like...

Code:
<!--#include file="connect.asp"--> 
<%
Function Test(strColumn,strTable,strCondition)
  set rst=server.createobject("adodb.recordset")
  sql="Select"&strColumn&"From"&strTable&"where"&strCondition
  rst.open sql,conn,1,3
  Test = rst(strColumn)
End Function

dim a
a=Test("price","BA","id="&1)
response.write a
%>
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