SQL error "Arguments are of the wrong type ..."

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • iam247@gmail.com

    #1

    SQL error "Arguments are of the wrong type ..."

    Hi

    I have a web page which receives information from a form (using
    request.form) and also attempts to look at an Access query to read in
    recoeds to a variable named rsGroup.

    When I have the following line commented, so it does not activate, I
    can successfully print all of the response.write' s below:

    rsGroup.Open strSQL, adoCon

    response.write( strSQL)
    response.write( "<P>")
    response.write( GroupSend)
    response.write( "<P>")
    response.write( request.form("G roupName"))
    response.write( "<P>")
    response.write( " " & request.form("S ubject"))
    response.write( "<P>")
    response.write( " " & request.form("C ontent"))

    response.write( strSQL) prints as:
    SELECT qrySendemail*Gr oupName FROM qrySendemail WHERE GroupName =
    'FOOTBALL'
    and works fine if I use it directly in an access query

    However when I uncomment

    rsGroup.Open strSQL, adoCon

    I get the following error message

    "Arguments are of the wrong type, are out of acceptable range, or are
    in conflict with one another"

    You will see I have several alternative SQL's (currently
    commented)which I have tried, all work OK when rsGroup.Open strSQL,
    adoCon is commented.

    I have several other pages using similar ado connections and generally
    similar code, which work OK.

    Any advice would be appreciated

    Note - I do realise I am querying an access query not a table; I will
    not be updating or deleting records in the query.

    Thanks ColinK

    Code:

    <%@ Language=VBScri pt %>

    <%
    'Dimension variables
    Dim objDC 'Holds the Database Connection Object
    Dim strSQL 'Holds the SQL query to query the database
    Dim rsGroup 'Holds the details of group members
    Dim GroupSend 'holds the group name to send to

    'insert the Group name to send to into the variable GroupSend
    GroupSend = (Request.Form(" GroupName"))

    'Create an ADO connection object on the server using the ADO Database
    connection object
    Set objDC = Server.CreateOb ject("ADODB.Con nection")

    'Set an active connection to the Connection object using a ****
    DSN-less connection ****
    objDC.Open "DRIVER={Micros oft Access Driver (*.mdb)}; DBQ=" &
    Server.MapPath( "../databases/GC1.mdb")

    'Create an ADO recordset object
    Set rsGroup = Server.CreateOb ject("ADODB.Rec ordset")

    ' request record for requested Groupid

    'NOTE first 2 sql's are currently commented
    'strSQL = "SELECT * FROM qrySendemail WHERE GroupName = '" &
    Request.Form("G roupName") &"' "
    'strSQL = "SELECT * FROM qrySendemail WHERE GroupName = 'FOOTBALL' "
    strSQL = "SELECT qrySendemail*Gr oupName FROM qrySendemail WHERE
    GroupName = 'FOOTBALL' "


    'Set the cursor type we are using so we can navigate through the
    recordset
    rsGroup.CursorT ype = 2

    'Open the recordset with the SQL query
    'rsGroup.Open strSQL, adoCon
    'rsGroup.Close

    response.write( strSQL)
    response.write( "<P>")
    response.write( GroupSend)
    response.write( "<P>")
    response.write( request.form("G roupName"))
    response.write( "<P>")
    response.write( " " & request.form("S ubject"))
    response.write( "<P>")
    response.write( " " & request.form("C ontent"))
    %>

  • Trevor Best

    #2
    Re: SQL error &quot;Argume nts are of the wrong type ...&quot;

    iam247@gmail.co m wrote:[color=blue]
    > However when I uncomment
    >
    > rsGroup.Open strSQL, adoCon
    >
    > I get the following error message
    >
    > "Arguments are of the wrong type, are out of acceptable range, or are
    > in conflict with one another"
    >
    > You will see I have several alternative SQL's (currently
    > commented)which I have tried, all work OK when rsGroup.Open strSQL,
    > adoCon is commented.
    >
    > I have several other pages using similar ado connections and generally
    > similar code, which work OK.[/color]

    The first thing I'd look at would be the reference to ADO or the
    inclusion of adovbs.inc but not both as they tend to conflict one
    another sometimes.

    Then look at the type of recordset you are opening as you don't specify
    one in that line of code.

    --
    [OO=00=OO]

    Comment

    Working...