I don't know why i am getting this error.

Please see my coding part, where i am facing this following error

Private pbat  As New ADODB.Parameter

            'in form load
              With pbat
             .Direction = adParamInput
             .Type = adVarChar
             .Size = 4
              End With 

             'saving part 
            [B]  pbat = Trim(Text1.Text) & "%"[/B] -here i faced the following error

How to rectify this error ?

6 Years
Discussion Span
Last Post by BitBlt

"pbat" is the parameter - appending to "SQL Select Query"

Private pbat  As New ADODB.Parameter
[B]pbat = Trim(Text1.Text) & "%"[/B]

-here i faced the following error


Still i am facing the same error:

Run time error: '3421'
Application uses a value of the wrong type for the current operation

Why i am facing this error?


There is a parameter expected in your SQL statement (which we have not seen). Please show the SQL statement, and the surrounding VB used to construct it. My guess is that your statement is using ODBC syntax incorrectly, so your driver is trying to interpret your varchar as an int. Cleaner way might be to just dynamically construct the SQL statement as a string and do away with the Parameter object altogether.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.