SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    May 2005
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Arguments are of the wrong type Error!!!

    Hey guys! I'm a beginner in ASP and I'm trying to figure out what this scripting language can give me, so I tried to develop a little web app. Here's my problem.
    I'm just trying to access the sql server database to do some web base reporting but this bull-**** error always hinder me from looking at the result of my report.
    "ADODB.Recordset (0x800A0BB9)
    Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another."



    this is my code

    Set objRS1=Server.CreateObject("ADODB.Recordset")objRS1.ActiveConnection=OpConn
    objRS1.CursorType = adOpenKeyset
    objRS1.LockType = adLockOptimistic
    objRS1.Open strSQL <======THIS IS WHERE THE ERROR OCCURS
    Number = objRS1.RecordCount

    IF NOT objRS1.EOF THEN
    objRS1.MoveFirst

    ScriptName = request.servervariables("ScriptName")

    Response.write "<TABLE WIDTH=""100%""><TR><TD><font size=1>"
    response.write "Showing page <b>" & CurrentPage & "</b> of <b>" & TotalPages & "</b>:&nbsp;&nbsp;Entries " & NumPerPageOf & " - " & NumPerPageTo & " of&nbsp;&nbsp;<b>" & Number & "</b> Records...<br>"
    Response.write "</font></TD><TD align=right>"

    Response.Write "</TD></TR></TABLE>"

    Response.Write ("<TABLE BORDER=0 CELLPADDING=2 CELLSPACING=1 WIDTH=""100%""><TR>")
    FOR i=0 to objRS1.fields.count-1
    fname = objRS1.fields(i).Name
    Response.Write ("<TH class=Header align=center><FONT SIZE=2 COLOR=white>")
    Response.Write fname & "</a></FONT></TH>"
    NEXT

    Response.Write ("</TR>")
    'This will display the field contents
    WHILE NOT objRS1.EOF
    count = count + 1

    IF strClass = "odd" THEN
    strClass = "even"
    ELSE
    strClass = "odd"
    END IF

    Response.Write ("<TR>")
    FOR i=0 TO objRS1.fields.count-1
    ThisRecord = objRS1(i)
    IF isNull(ThisRecord) THEN
    ThisRecord = "&nbsp;"
    END IF
    Response.Write ("<td valign=top CLASS=" & strClass & ">")
    Response.Write ThisRecord
    Response.Write ("</td>")
    NEXT
    Response.Write ("</TR>")
    objRS1.MoveNext
    WEND

    Response.Write ("</TABLE>")

    objRs1.close
    Set objRs1 = NOTHING
    END IF

    The connection string is located in a separate ASP file which was included in this particular page. I already included the ADOVBS.INC and still receive the error. I also tried referencing ADO 2.7 in the PROJECTS --> REFERENCES but it didn't work too. I don't know what's going on? Please help me!!! Thanks in advance!

  2. #2
    HardCoder md_irfan_amu's Avatar
    Join Date
    May 2005
    Location
    Asia
    Posts
    215
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you just go through the open command ...

    first argument is connection and not the querystring....

    so write
    objRS1.Open opConn, strSQL
    Irfan
    Find Tutors Easyway to get connect with your tutor in india

  3. #3
    SitePoint Member
    Join Date
    May 2005
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I did your advice md_irfam_amu but it still gave me the same error...

  4. #4
    HardCoder md_irfan_amu's Avatar
    Join Date
    May 2005
    Location
    Asia
    Posts
    215
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Set objRS1=Server.CreateObject("ADODB.Recordset")
    objRS1.ActiveConnection=OpConn
    objRS1.CursorType = adOpenKeyset
    objRS1.LockType = adLockOptimistic
    objRS1.Open strSQL <======THIS IS WHERE THE ERROR OCCURS
    Number = objRS1.RecordCount

    wheather u open OpConn alredy somewhere or not....
    if not then first set the connection and connection string

    like
    set con = server.createobject("adodb.connection")
    con.connectionstring="provider and what ever ur data base etc"

    then con.open

    then write your code...
    Irfan
    Find Tutors Easyway to get connect with your tutor in india

  5. #5
    SitePoint Enthusiast hombre_de_las_ca's Avatar
    Join Date
    Apr 2005
    Location
    Bangalore, India
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    have you put this at the top of yur page:
    <!-- metadata type="typelib" file="c:\program files\common files\system\ado\msado15.dll" -->
    this is required if u are using the ado constant's name.
    CaveMan
    Don't ask what your Country can do for you,
    Ask what you can do for your Country.

  6. #6
    ALT.NET - because we need it silver trophybronze trophy dhtmlgod's Avatar
    Join Date
    Jul 2001
    Location
    Scotland
    Posts
    4,836
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Whats the SQL?

  7. #7
    SitePoint Member
    Join Date
    May 2005
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    to md_irfan_amu,
    hombre,
    dhtmlgod:


    Well, I have tried all your suggestions just before you have made them...but i still receive errors...Now I'm trying to execute the query using the command object like this:

    Set cmd=server.CreateObject("ADODB.command")
    cmd.CommandText=strSQL
    cmd.CommandType=adCmdText
    cmd.ActiveConnection=OpConn
    Set objRS1=cmd.Execute
    Number = objRS1.RecordCount

    But it gave me another sort of error:

    Microsoft OLE DB Provider for SQL Server (0x80040E0C)
    Command text was not set for the command object.

    Could you give me some more ideas on how to debug this error?


Bookmarks

Posting Permissions

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