473,626 Members | 3,389 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 2375
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.ToBase6 4String and Convert.FromBas e64String, in my view. There
are other ways which will take significantly less space, but are more
prone to problems.

--
Jon Skeet - <sk***@pobox.co m>
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.co m> píse v diskusním príspevku
news:MP******** *************** *@msnews.micros oft.com...
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.ToBase6 4String and Convert.FromBas e64String, in my view. There
are other ways which will take significantly less space, but are more
prone to problems.

--
Jon Skeet - <sk***@pobox.co m>
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
11494
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 ( STL )" ? So I would like to generate some objects ( of different classes ) with a C++ program and would like to make it permanent / persistent, so that
12
7709
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 one column per element, each column is VARCHAR Does MySQL has anything special for XML data? Is there any software which helps to store XML data in MySQL
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 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...
2
1250
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 should be output by XSLT. Question - what is the best representation in XML for this data?
9
24781
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 longer text information in a column..? Thanks.
2
3515
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 in my local system, Is there any way of retrieving the image datatype and store it as a file in our local system in c#
5
10620
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 the dataset because I don't know what datatype to set the dataset column and then set this image to. I saw an example where someone defended a datatable in the global class and defined the column as an object, however, when I define a strongly...
6
2714
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, every now and then the client would timeout and have to re-initiate the request... TIA!
4
2996
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 type colum with the variable length of 26 bytes. This is the first time I ran into such way of storing multiple selections in a single Image data type. Is this a better alternative than to store into a One-to-Many tables? If so then I'll have...
13
3408
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. The first column is always an English
0
8205
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8713
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8644
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7206
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6126
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4094
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4208
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1817
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1516
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.