Results 1 to 2 of 2

Thread: correct use of a function?

  1. #1
    Join Date
    Dec 2004
    Posts
    152

    correct use of a function?

    Hi There,
    Im doing a lot of access to a db and retrieval of all informaiton in numerous tables. Now i know that should be using stored procedures bu i am trying to get my head into functions and thus have the below question.

    Ive created a function shown below called getALL. I want it to return a recordset so as I can then process the information retrieved.
    In my sub, how do i use this function and continue processing after the retrieval of the recordset. I start erroring when i attempt to code use and though sumone could look over.

    cheers

    my function which is defined in a SSI
    Conn (the connection) is defined in another SSI.

    Code:
    function getAll(tableName) 
        
                    Set RS = Server.CreateObject("ADODB.Recordset") 
    	strSQL = "SELECT * FROM "&dbName
    	RS.Open strSQL, Conn 
                    getAll=RS
    	
    end function
    Code:
    sub getSelectTable(tableName)  
    
                    tabN=tableName
    	function call here i assume
    	RS.MoveFirst 
    
                    'process recordset here

  2. #2
    Join Date
    Sep 2005
    Posts
    20
    Hello .........

    Your getAll(..) function is OK but callit like this, I am sure it will not raise any error

    sub getSelectTable(tableName)

    tabN=tableName
    Set RS = Server.CreateObject("ADODB.Recordset")
    Set RS = getAll(tabN)
    RS.MoveFirst

    'process recordset here



    If it shows error then try after comment then following line

    Set RS = Server.CreateObject("ADODB.Recordset")

Similar Threads

  1. FUNCTION OR PROCEDURE? : Output of resultset
    By numbenator in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 0
    Last Post: 04 Aug 2005, 06:16 AM

Posting Permissions

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