|
Posted by Erland Sommarskog on 10/01/03 11:21
(hurricane@tin.it) writes:
> I have the necessity of make a stored procedure that convert one
> parameter passed from base64 to binary before store in a field image.
>
>
> Is possible? How?
Maybe, but it would probably be very kludgy. You cannot assign values
to an image variable, so you cannot write a user-defined function
that accepts a Base64 string and converts it to image. You would
have to slice up the string into 8000 char long pieces, and convert
piece by piece, and use WRITETEXT or UPDATETEXT to add data to the
image column.
> I have this necessity because a lot of page made in ASP get the binary
> and put to view the image in a site.
>
> The situation is the same:
>
> RealBasic ---> ODBC ---> SQL Server
>
> If I try to put directly the binary an error occour:
> Unclosed quotation mark before the character string '? ???'
It sounds as if you compose an SQL statement and pass this to
SQL Server, and then try to put the binary in a string and then
things go downhill from there.
The best option is to find out how you compose parameterized statements
from RealBasic. Then you can pass the binary value as a binary,
and you would specify that the parameter is binary. I don't know
RealBasic, and I have limited experience of the ODBC API. But I know
that the ODBC API supports it.
The other alternative is to convert the binary to a hex string, and
then pass it, prefixed with 0x, but not enclosed in quotes. Here is
a very simple example:
DECLARE @x varbinar(20)
SELECT @x = 0x4711ABCF
--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp
[Back to original message]
|