SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 3 of 3
  1. #1
    Senior Member
    Join Date
    Jun 2006
    Location
    India
    Posts
    117
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Return a record set from a function

    Hi,

    I have written a function to return a recordset,so that I can use this function for the scripts.

    Public function Execquery(query)
    Record1=CreateObject("ADODB.Recordset")
    Set Record1=dbconn.execute(Sqlquery)
    set Execquery=Record1
    end function

    'calling the function from script
    record2=CreateObject("ADODB.Recordset")
    record2=Execquery(query)
    empid=record1.fields("empid")
    I am getting an error at this line as "Object doesn't support this propery or method"

    msgbox empid

    Can you please help me in this regard?

    thanks
    Kooltestingkings

  2. #2
    Member
    Join Date
    Dec 2007
    Posts
    49
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Return a record set from a function

    Yuou can try this :
    Public function Execquery(query)
    Record1=CreateObject("ADODB.Recordset")
    Set Record1=dbconn.execute(Sqlquery)
    set Execquery=Record1
    end function

    'calling the function from script
    record2=CreateObject("ADODB.Recordset")
    record2=Execquery(query)
    empid=record1.fields("empid") .value
    (i use number like record1.fields(0).value )
    Also is the 2nd statement in Execquery is it
    Set Record1=dbconn.execute( Sqlquery )
    or
    Set Record1=dbconn.execute(query)

  3. #3
    SQA Knight
    Join Date
    Jul 1999
    Location
    Grand Rapids, MI
    Posts
    3,727
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Return a record set from a function

    Record1 is a private variable within the ExecuteQuery() function.

    So you can't use it outside that function (empid=record1.fields("empid")).

    This shows the importance of using both the Option Explicit at the top of EVERY test script and EVERY shared library, which will force you to declare all variables before attempting to use them.

    (The original developers of vbScript should have been shot for defaulting the runtime to Option NOT Explicit).

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 11.54%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 07:00 PM.

Copyright BetaSoft Inc.