B4J Question MS-sql varbinay / blob

victormedranop

Well-Known Member
Licensed User
Longtime User
hi i,m trying to get a varbinary record from a microsoft sql server.
Connection works ok,

but here is my problem

i got this error

com.microsoft.sqlserver.jdbc.SQLServerException: The conversion of the varchar value '02200000160' overflowed an int column.

he is my code
B4X:
rs = sql1.ExecQuery($"select  * from XX  where XXXX  = ${XX}"$)

Log($"select  * from FOTOS  where Cedula  = ${cedula}"$)

Log(rs.ColumnCount)  

Do While rs.NextRow ----------> the error start here

Dim buffer() As Byte

buffer = rs.GetBlob("Imagen")

Loop


Any help will be apreciated

Victor
 

keirS

Well-Known Member
Licensed User
Longtime User
Need to know more information than that. What type is cedula in B4x and what type is Cedula in SQL Server? It is true that the value of 2200000160 is of greater size than the maximum value of an Int column in SQL server which is 2147483647 .
 
Upvote 0

victormedranop

Well-Known Member
Licensed User
Longtime User
its a string, for index, the column i'am accessing is in sql server and it's a varbinary type (an image).

Victor
 
Upvote 0

rraswisak

Active Member
Licensed User
Longtime User
if XXXX data type was string then i think you miss apostrophe in your where syntax, it should be:

B4X:
rs = sql1.ExecQuery($"select  * from XX  where XXXX  = '${XX}' "$)
sorry not tested
 
Upvote 0

victormedranop

Well-Known Member
Licensed User
Longtime User
i found my problem.
using web service in b4j

B4X:
srvr.AddHandler("/imagen", "ConsultaImagen", False)

i need to initialize the sql.ini in main class, not in the class ConsultaImagen.

when i did that works like expected,

thanks.
 
Upvote 0
Top