Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6015371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:49:36+00:00 2026-05-23T02:49:36+00:00

I have a little problem with vbscript I have declared some function with passing

  • 0

I have a little problem with vbscript
I have declared some function with passing the result set from a sql query like an argument and the problem is that the function showData accept the argument like an object not like a resultset

function get_count(conn)
    dim query, size
    Set query = Server.CreateObject("ADODB.Recordset")
    set query = conn.Execute("select count(*) as size from doctor")
    size = query.Fields("size")
    get_count = size
end function
function get_rows_from_to(from,size,conn)
    dim result
    Set result = Server.CreateObject("ADODB.Recordset")
    set result = conn.Execute("SELECT name, surname,family,egn,citizenship FROM doctor limit "&from&","&size&"")
    get_rows_from_to = result
end function
Sub showData(objRS)
    dim isEven
    isEven = false
    Response.Write "<table>"
    Response.Write "<tr>"
    Response.Write "<th >Име</th><th >Презиме</th><th >Фамилия</th><th >ЕГН</th><th >Гражданство</td>"
    Response.Write "</tr>"
    While Not objRS.EOF
        Response.Write "<tr>"
        if isEven then
            Response.Write "<td style = 'background-color :#e9ebf2'>"&objRS.Fields("name")&"</td>"&_
                "<td style = 'background-color :#e9ebf2'>"&objRS.Fields("surname")&"</td>"&_
                "<td style = 'background-color :#e9ebf2'>"&objRS.Fields("family")&"</td>"&_
                "<td style = 'background-color :#e9ebf2'>"&objRS.Fields("egn")&"</td>"&_
                "<td style = 'background-color :#e9ebf2'>"&objRS.Fields("citizenship")&"</td>"
            isEven = false
        else
            Response.Write "<td>"&objRS.Fields("name")&"</td><td>"&objRS.Fields("surname")&"</td><td>"&objRS.Fields("family")&"</td><td>"&objRS.Fields("egn")&"</td><td>"&objRS.Fields("citizenship")&"</td>"
            isEven = true
        end if
        Response.Write "</tr>"
        objRS.MoveNext
    Wend 
    Response.Write "</table>"
    objRS.Close
end sub
const ROWS_PER_PAGE = 10
Dim sConnection, conn , result,pages,selPage,from,lenght,pos,size

from = 0
lenght = 10
pos = 1
size = 0
sConnection = "DRIVER={MySQL ODBC 5.1 Driver}; SERVER=localhost; DATABASE=docunion; UID=root;PASSWORD=root; OPTION=3" 

Set conn = Server.CreateObject("ADODB.Connection") 
Set result = Server.CreateObject("ADODB.Recordset")
conn.Open sConnection

size = get_count (conn)
size = CInt(size)
if size  > 0 then
    pages = size / 10
    lenght = (ROWS_PER_PAGE*pos)
    set result = get_rows_from_to(from,lenght,conn)
    from = lenght + 1
    pos = pos + 1
    showData(result)
else
    Set result = Nothing
    conn.Close
    Set conn = Nothing
end if

Could anyone tell me where is the problem here. I’m new in vbscript. This is the error in the function showData with the object objRS

Microsoft VBScript runtime error '800a01b6'
Object doesn't support this property or method: 'EOF'
/index.asp, line 57
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T02:49:37+00:00Added an answer on May 23, 2026 at 2:49 am

    The main problem is that functions that return an object reference must use Set for their return value:

    function get_rows_from_to(from,size,conn)
        ' ...
        set get_rows_from_to = result
    end function
    

    A few other hints:

    There is no need to declare functions before you use them. You can put all your function declarations at the end of the script and keep the main script body at the top.

    This is needlessly redundant:

    function get_rows_from_to(from,size,conn)
        dim result
        Set result = Server.CreateObject("ADODB.Recordset")
        set result = conn.Execute("SELECT name, surname,family,egn,citizenship FROM doctor limit "&from&","&size&"")
        set get_rows_from_to = result
    end function
    

    and is equivalent to this

    function get_rows_from_to(from,size,conn)
        set get_rows_from_to = conn.Execute("SELECT name, surname,family,egn,citizenship FROM doctor limit " & from & "," & size &"")
    end function 
    

    conn.Execute() already returns an ADODB.RecordSet. It makes no sense to create a blank one via Server.CreateObject() before. In fact, all your Set xyz = Server.CreateObject("ADODB.Recordset") lines are superfluous.

    There is no sense in creating a separate variable for the return value in Functions. The function is its return value:

    function getFoo()
        getFoo = "foo"
    end function
    

    Two final tips:

    • Always use Option Explicit.
    • Always use Server.HtmlEncode() on any piece of data you output to the page. This is even more important than all the other tips.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a little problem with multiline UILabel, my UILabel text like starts from
I have a little problem with a simple vbScript. The script has to run
I have little problem. I can't use AcceptVerb.Get on some ASP.NET MVC actions because
i have a little problem with the hover function with mousemove. But what is
I'm have little problem in retrieving the data from a table here's the code:
I have a little problem - i would can get with this query topics
I have a little problem with my click event. I have an AJAX function
I have a little problem. I have a program that will draw wave function
I have a little problem, I just made a menu with some asp:hyperlink structured
Hi I have a little problem. I must exec query in that style. In

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.