Application uses a value of the wrong type for the current operation

Discussion in 'C#' started by jhd1967, Mar 23, 2009.

  1. #1
    i have been struggling with this error for a while , i changed to many times to make sure no error but no luck


    Error on line 29
    strsql.Parameters("@columna") = strmake




    <%

    Dim objCN ' ADO Connection object
    Dim objRS ' ADO Recordset object
    Dim strsql ' SQL query string
    Dim RecordsArray ' To hold the Array returned by GetRows
    Dim i ' A counter variable
    Dim strmake
    Dim objDBParam3

    ' Create a connection object
    Set objCN = Server.CreateObject("ADODB.Connection")

    ' Connect to the data source
    objCN.Open "coonection;"
    set strsql = Server.CreateObject("ADODB.Command")
    strsql.ActiveConnection = objCN
    strsql.CommandText = "SELECT model ,CAT_ID FROM new WHERE CAT_ID = ? "
    strsql.CommandType = 1

    strmake = "1"
    If (Request.QueryString("catid") <> "") Then
    strmake = Request.QueryString("catid")
    End If

    set objDBParam3 = strsql.CreateParameter("@columna",5, 1, -1)
    strsql.Parameters.Append objDBParam3
    strsql.Parameters("@columna") = strmake
    set objDBParam3 = Nothing
    set objRS = strsql.Execute

    If objRS.EOF Then

    Response.Write "Erreur"
    Response.End
    end if
    RecordsArray = objRS.GetRows()

    %>
    <input name="marque" type="hidden" value="<%=RecordsArray(2, i) %>" >
    <select name="model" onchange="getCarburation(<%= RecordsArray(1, i) %>,this.value)">
    <option value="">Tous</option>
    <% For i = 0 To UBound(RecordsArray, 2)%>


    <option value="<%=RecordsArray(0, i)%>"><%=RecordsArray(0, i)%></option>
    <%
    Next
    Response.write "</select>"
    'End if
    objRS.Close
    objCN.Close
    Set objCN = Nothing
    Set objRS = Nothing
    %>

    I appreciate your help
     
    jhd1967, Mar 23, 2009 IP
  2. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #2
    Have you tried:
    strsql.Parameters("@columna") = Int(strmake)

    or:
    strsql.Parameters("@columna") = Val(strmake)
     
    camjohnson95, Mar 23, 2009 IP
  3. jhd1967

    jhd1967 Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I tried this one here:
    strsql.Parameters("@columna") = Int(strmake)
    but getting this error:

    Description: Type mismatch: '[string: "make"]'

    the other one
    strsql.Parameters("@columna") = Val(strmake)

    just keep sending errors Val(strmake)
    Thank you
     
    jhd1967, Mar 25, 2009 IP