Search code examples
asp-classic

Application uses a value of the wrong type for the current operation in classic asp


I am calling one stored procedure using the following code:

m_objCmd.CommandText = "StoredProc_Name"
m_objCmd.Parameters.Append m_objCmd.CreateParameter("@UserID", 3, 1, 0, UserID)
m_objCmd.Parameters.Append m_objCmd.CreateParameter("@UserTypeID", 3, 1, 0, UserTypeID)
m_objCmd.Parameters.Append m_objCmd.CreateParameter("@AccessToken", 202, 1, 100, AccessToken)
m_objCmd.Parameters.Append m_objCmd.CreateParameter("@TokenExpiration", 135, 1, 0, TokenExpiration)
m_objCmd.Parameters.Append m_objCmd.CreateParameter("@RefreshToken", 202, 1, 100, RefreshToken)

rsUserData.Open m_objCmd, , adOpenStatic, adLockReadOnly  

In above:

  • @UserID is a 'int' dataType
  • @UserTypeID is 'int'
  • @AccessToken is nVarchar(100)
  • @TokenExpiration is datatime(2)
  • @RefreshToken is nVarchar(100)

But here I am getting the error:

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

Can any one help me please.


Solution

  • I had this same problem just a few days ago. My problem was overflow as Kul-Tigin suggests below.

    I was trying to insert a huge string 17,000+ characters in length and I received exactly the same error as you. I then opted to save the string in a text file and I used the table as a file locator so-to-speak.

    Check the length of the values in the following:

    • @UserID is a 'int' dataType
    • @UserTypeID is 'int'
    • @AccessToken is nVarchar(100)
    • @TokenExpiration is datatime(2)
    • @RefreshToken is nVarchar(100)