473,771 Members | 2,372 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 2386
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
11520
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
7724
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
1254
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
24793
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
3523
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
10634
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
2731
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
3015
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
3416
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
9619
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10260
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
10102
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...
1
10038
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9910
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5354
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
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2850
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.