|
How To: Inserting Binary Data using XML (15123 Requests)
Answer provided by Joshua Allen.
The Base 64 algorithm used by SQL Server 2000 is the same one specified in RFC 1521. Below is some sample code that you can use to do base64 encoding/decoding according to the RFC.
However, the best method for inserting base64 encoded data is to use a schema and specify the data type as bin.base64. You can then use this schema with an updategram or with BulkLoading and the data will be automatically decoded into the binary field in the database.
Of course, you could always write your own routines to manipulate the blob fields directly in the database, but I think it is much easier to just post an updategram.
C++ Sample Code:
Base64Coder.cpp
Base64Coder.h
code.cpp
Feedback
# Convert Binary to XML
8/11/2003 11:58 AM
Tom Grisafe
Now how would you go the other direction, Binary Data back into XML in SQL Server.
# re: How To: Inserting Binary Data using XML
12/4/2003 3:38 PM
jim
other examples of this approach? c#, vb, etc?
# re: How To: Inserting Binary Data using XML
6/14/2005 10:20 AM
dominic grisafe
hi uncle tom its dominic i looked up your name on google and read those letters you wrote about the catholic church. just saying hi.
love,
dominic
# re: How To: Inserting Binary Data using XML
8/19/2005 2:17 PM
tim
Ok, thanks! But...
1) How do we write a stored procedure that accepts an XML fragment containing base-64 encoded data, and automagically converts that b64 string to binary for updating an image column?
2) And what would that XML document look like exactly? You say we need a schema...so how would I craft an XML fragment to pass into this procedure?
For example, let's say I want to insert something like:
<employees>
<employee>
<id>5</id>
<photoAsBase64>AQAAE83392D23=//</photoAsBase64>
</employee>
...etc...
</employees>
Thank you
# how to parse binary data from xml
3/17/2006 12:59 AM
selva
how to parse binary data from the xml
loading mxl file and retrive binary data and save as exe file in vc++
sample code in vc++
# re: How To: Inserting Binary Data using XML
4/11/2006 11:48 PM
jgtjtg dad
tjytrjyrjkryk
# re: How To: Inserting Binary Data using XML
4/11/2006 11:48 PM
jgtjtg dad
tjytrjyrjkryk iryiyi iiyt itri
# qvys fdsakleow
10/30/2007 5:16 PM
nqmcbop@mail.com
imejn blter fdak cidonsjav zeodn sdfn xvkjscp
# qvys fdsakleow
10/30/2007 5:18 PM
nqmcbop@mail.com
imejn blter fdak cidonsjav zeodn sdfn xvkjscp
# re: How To: Inserting Binary Data using XML
11/11/2008 3:06 PM
asdf
wtfh
# re: How To: Inserting Binary Data using XML
11/11/2008 3:07 PM
asdf
wtfh
# re: How To: Inserting Binary Data using XML
1/4/2010 12:45 AM
fgd
fdsgf
# How to: Convert image datatype (from SQLServer 2000) to base64
1/4/2010 1:03 PM
Aymeé
Please, How can i may convert image datatype (from SQLServer 2000) to base64. I need this for import photos stored in a sqlserver database to a LDAP directory that has Gosa as its fronted. Thank you so much.
|