473,498 Members | 1,828 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

store binary data in SQL text column

Hi,

I am trying to store binary data (e. g. image) in MS SQL Server 2000 column
which data type is [text]. I understand I could store binary data easily in
MS SQL [image] type but I have only [text] column available in the database
which I don't want to change.

I think the trouble is in .net data type string which actually is a unicode
string. I have an array of bytes (= binary data) which I need to pass
somehow to the stored procedure which input parameter is of type [text].
Correspondant type to SQL [text] is string in .NET to which the array of
bytes must be sooner or later and explicitly or implicitly converted. Here I
think the data is
non-reversibly changed.

Thanks in advance for any hint

Pavel


Nov 22 '05 #1
2 2360
PearCZ <pe****@online.nospam> wrote:
I am trying to store binary data (e. g. image) in MS SQL Server 2000 column
which data type is [text]. I understand I could store binary data easily in
MS SQL [image] type but I have only [text] column available in the database
which I don't want to change.

I think the trouble is in .net data type string which actually is a unicode
string. I have an array of bytes (= binary data) which I need to pass
somehow to the stored procedure which input parameter is of type [text].
Correspondant type to SQL [text] is string in .NET to which the array of
bytes must be sooner or later and explicitly or implicitly converted. Here I
think the data is non-reversibly changed.

Thanks in advance for any hint


The best (cleanest, least prone to error) way here is to use
Convert.ToBase64String and Convert.FromBase64String, in my view. There
are other ways which will take significantly less space, but are more
prone to problems.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 22 '05 #2
Thanks, this works.

"Jon Skeet [C# MVP]" <sk***@pobox.com> píse v diskusním príspevku
news:MP************************@msnews.microsoft.c om...
PearCZ <pe****@online.nospam> wrote:
I am trying to store binary data (e. g. image) in MS SQL Server 2000 column which data type is [text]. I understand I could store binary data easily in MS SQL [image] type but I have only [text] column available in the database which I don't want to change.

I think the trouble is in .net data type string which actually is a unicode string. I have an array of bytes (= binary data) which I need to pass
somehow to the stored procedure which input parameter is of type [text].
Correspondant type to SQL [text] is string in .NET to which the array of
bytes must be sooner or later and explicitly or implicitly converted. Here I think the data is non-reversibly changed.

Thanks in advance for any hint


The best (cleanest, least prone to error) way here is to use
Convert.ToBase64String and Convert.FromBase64String, in my view. There
are other ways which will take significantly less space, but are more
prone to problems.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
11453
by: Rolf Hemmerling | last post by:
Hello ! Beginner's question: What ist the easiest way to store and save objects in a file generated by a C++ program, by using the "standard C++ library" and/or "Standard Template Library (...
12
7691
by: jacob nikom | last post by:
Hi, I would like to store XML files in MySQL. What is the best solution: 1. Convert it to string and store it as CLOB/text 2. Serialize it and store as byte array 3. Flatten it out and create...
2
414
by: PearCZ | last post by:
Hi, I am trying to store binary data (e. g. image) in MS SQL Server 2000 column which data type is . I understand I could store binary data easily in MS SQL type but I have only column...
2
1245
by: Stoggers | last post by:
Hi, I have the following requirement: Extract binary data from column in RDBMS and store in XML. Process document using XSLT, retaining binary data - ie if x'00 was in the column then x'00...
9
24773
by: ssb | last post by:
Hi, As I understand, in MS-Access, the maximum length of data type "TEXT" is 255. Therefore, I am able to store a maximum of 255 characters only in the column cells. Is there a way to store...
2
3509
by: kabin selvam | last post by:
Hi, my scenario is like this, I have my document (word.or excel or pdf) stored a s a binary value(image datatype) in database, I need it to convert back into thedocument and save it as the file...
5
10609
by: moondaddy | last post by:
I'm caching a dataset in an asp.net session variable to hold a user's data. one data item I need to store is an image the user uploaded. My problem is that I don't know how to get the image into...
6
2699
by: | last post by:
Hi all, is there a better way to stream binary data stored in a table in sql 2005 to a browser in .net 2.0? Or is the code same as in .net 1.1? We noticed that in certain heavy load scenarios,...
4
2978
by: serge | last post by:
I was working on figuring out where a certain application was storing the multiple selection choices I was doing through the app. I finally figured out that they were being store in an IMAGE data...
13
3386
by: liujiaping | last post by:
Hi, all. I have a dictionary-like file which has the following format: first 4 column 7 is 9 a 23 word 134 .... Every line has two columns....
0
7005
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7168
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7210
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6891
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7381
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4595
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3096
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1424
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
293
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.