Link to home
Start Free TrialLog in
Avatar of zimmer9
zimmer9Flag for United States of America

asked on

How to resolve a Run time error '-2147217833(80040e57) [MERANT] [ODBC Sybase Wire Protocol driver] [SQL Server] Arithmetic overflow during implicit conversion of INT value '1435' to a TINYINT field ?

I am developing an Access application using Access 2003 with an MDB file. I call a Sybase Stored Procedure (using Sybase version 12.4) which I can only execute. I don't have rights to read any of the stored procedure's underlying tables.

I attached a code snippet of a command button On Click event in which I execute the Stored Procedure.
I have the following information on this stored procedure titled getTATGATCDSAByAccount:
When I run the application and click on the command button, the compiler stops at the
Execute command to run the stored procedure which is shown in the attached code snippet.
This is the line at which the compiler stops: Set recNameAdress = .Execute
with a Run time error '-2147217833(80040e57) [MERANT] [ODBC Sybase Wire Protocol driver] [SQL Server] Arithmetic overflow during implicit conversion of INT value '1435' to a TINYINT field  ?

exec getTATGATCDSAByAccount @ApplnNm='test', @accountNumber='0A5005085',
@accountSystem=1435,
@selectFields='accountNumber, accountSystem, accountStatus, accountCategory, countryOfCitizenship, countryOfResidence, fullName1, address1, city, stateCode, countryCode, postalCode, accountClassification, taxID'

The @selectFields is the output variable. If you leave it out you get dozens of fields back. If you put one field name, you only get 1 field back. For example:

exec getTATGATCDSAByAccount @ApplnNm='test', @accountNumber='0A5005085',
@accountSystem=1435,
@selectFields= 'accountCategory'

exec getTATGATCDSAByAccount @ApplnNm='test', @accountNumber='0A5005085',
@accountSystem=1435,
@selectFields='accountNumber, accountSystem, accountStatus, accountCategory'

returns 4 fields



Private Sub Command9_Click()
Dim strApplication   As String
Dim intAccountSystem As Integer
Dim strAccount As String
Dim rstQueryFS As ADODB.Recordset
Dim fld As ADODB.Field
Dim intCol As Integer
Dim intRow As Integer
Dim strSQL As String
Dim com As ADODB.Command
Dim strUserName As String
Dim strValue1 As String
Dim strValue2 As String
Dim strValue3 As String
Dim recNameAdress As ADODB.Recordset
Dim cmd As ADODB.Command
Dim strFullName As String
Dim oConn
 
Set oConn = CreateObject("ADODB.Connection")
 
oConn.Open "DSN=PAP_ED_TEST1;" & _
           "Uid=nitod;" & _
           "Pwd=*******"
 
strApplication = "test"
strAccountNumber = "0A5005085"
intAccountSystem = "1435"
 
Set cmd = New ADODB.Command
 
With cmd
    .ActiveConnection = oConn
    .CommandType = adCmdStoredProc
    .CommandText = "getTATGATCDSAByAccount"
    .Parameters.Append .CreateParameter("@application", adVarChar, adParamInput, 15, strApplication)
    .Parameters.Append .CreateParameter("@accountNumber", adVarChar, adParamInput, 9, strAccountNumber)
    .Parameters.Append .CreateParameter("@accountSystem", adInteger, adParamInput, 4, intAccountSystem)
    Set recNameAdress = .Execute
End With

Open in new window

Avatar of thecodist
thecodist
Flag of United States of America image

Tinyint in MS SQL Server (which is originally based on Sybase) has a max value of 255. It is likely the same in Sybase. You can try a value of 255 and then 256 for intAccountSystem to verify.

TheCodist
Are you getting different results when you execute from a query window versus running in code? If so, you might try executing EXACTLY the same statement in code that you are in your query editor just to see if you still get the same results.
For instance:

.CommandType = adText
.CommandText = "exec getTATGATCDSAByAccount @ApplnNm='test', @accountNumber='0A5005085'"
.CommandText = .CommandText & ",@accountSystem=1435,@selectFields='accountNumber"
.CommandText = .CommandText & ", accountSystem, accountStatus, accountCategory'"
Avatar of zimmer9

ASKER

I placed code that I tried in the attached snippet with you last suggestion in mind.
I got an error on the following line:
.CommandType = adText

Run time error '3001':
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
-----------------------------------------------------------------------------------------------------------------------
Set cmd = New ADODB.Command
 
With cmd
    .ActiveConnection = oConn
    .CommandType = adText
    .CommandText = "exec getTATGATCDSAByAccount @ApplnNm='test', @accountNumber='0A5005085'"
    .CommandText = .CommandText & ",@accountSystem=1435,@selectFields='accountNumber"
    .CommandText = .CommandText & ", accountSystem, accountStatus, accountCategory'"
   
        Set recNameAdress = .Execute
End With

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of thecodist
thecodist
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial