Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2004
    Posts
    77

    Unanswered: 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
    %>

  2. #2
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    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
    %>

Posting Permissions

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