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

I call 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 the above example:

  • @UserID is the data type 'int'
  • @UserTypeID is 'int'
  • @AccessToken - nVarchar (100)
  • @TokenExpiration is the time (2)
  • @RefreshToken - nVarchar (100)

But here I get the error message:

The application uses the wrong type value for the current operation.

Can someone help me.

+6
source share
4 answers

I had the same problem just a few days ago. My problem was crowded, as Kul-Tigin suggests below.

I tried to insert a huge string with a length of 17,000 characters and got the same error as you. Then I decided to save the string in a text file, and I used this table as a file locator that says so.

Check the length of the following values:

  • @UserID is the data type 'int'
  • @UserTypeID - 'int'
  • @AccessToken is nVarchar (100)
  • @TokenExpiration is the date (2)
  • @RefreshToken is nVarchar (100)
+7
source

It seems that there is an overflow or the wrong type. For example, an AccessToken may exceed 100. Check all of them. And if necessary, convert the variables to your subtypes (especially strings). Some third-party components may return options and cause this. i.e.

 ... ("@AccessToken", 202, 1, 100, CStr(AccessToken)) ... ("@UserID", 3, 1, 0, CLng(UserID)) .. 
+1
source

Today I solved a similar problem by limiting the value of a variable to the value of the column data.

eg. if one of the column sizes is Varchar (500) and the display value contains more than 500 characters. he will throw this exception in ADODB (VB6.0)

you can solve this by increasing the size of the column data or by limiting the value to 500 characters, in vb6.0 u you can use Left ([variable_name], 500)

+1
source

Perhaps your piece of code in your question is simply incomplete, but I would expect this line to be present for your use too: -

  m_objCmd.CommandType = adCmdStoredProc 
0
source

Source: https://habr.com/ru/post/902919/


All Articles