473,396 Members | 2,121 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to store/retrieve binary data in/from SQL server DB?

I remember that there are functions to do it, but I forgot their names.

Anyone can give me a help?

Thank you.

David
Jul 6 '06 #1
4 1574

IDataReader has a .GetBytes method.

Something like this:
object o = dataReader.GetValue (123);

Console.WriteLine ("");

byte[] byteCodes = new byte[8];

long len = dataReader.GetBytes(123, 0, byteCodes, 0, 8);
Console.Write("Byte codes: ");

for (int i = 0; i < len; i++)

{

Console.Write(byteCodes[i].ToString("x"));

}

}
That was getting a timestamp value (8 length). You'll need to rework it, if
the length is unknown.

123 represents the ordinal position of the select statement.

Select lastname, firstname from Emp
lastname ordinal is 0
firstname ordinal is 1

I used 123 so it would stand out.

"david" <da***@discussions.microsoft.comwrote in message
news:E1**********************************@microsof t.com...
I remember that there are functions to do it, but I forgot their names.

Anyone can give me a help?

Thank you.

David

Jul 6 '06 #2
thanks.
Do you know any stored function to do it?

David

"sloan" wrote:
>
IDataReader has a .GetBytes method.

Something like this:
object o = dataReader.GetValue (123);

Console.WriteLine ("");

byte[] byteCodes = new byte[8];

long len = dataReader.GetBytes(123, 0, byteCodes, 0, 8);
Console.Write("Byte codes: ");

for (int i = 0; i < len; i++)

{

Console.Write(byteCodes[i].ToString("x"));

}

}
That was getting a timestamp value (8 length). You'll need to rework it, if
the length is unknown.

123 represents the ordinal position of the select statement.

Select lastname, firstname from Emp
lastname ordinal is 0
firstname ordinal is 1

I used 123 so it would stand out.

"david" <da***@discussions.microsoft.comwrote in message
news:E1**********************************@microsof t.com...
I remember that there are functions to do it, but I forgot their names.

Anyone can give me a help?

Thank you.

David


Jul 6 '06 #3
Yes, here's an example that allows upload and download of files and binary
storage of them in SQL Server.
http://SteveOrr.net/articles/EasyUploads.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net

"david" <da***@discussions.microsoft.comwrote in message
news:E1**********************************@microsof t.com...
>I remember that there are functions to do it, but I forgot their names.

Anyone can give me a help?

Thank you.

David

Jul 7 '06 #4

(another) nice write up Steve.

"Steve C. Orr [MVP, MCSD]" <St***@Orr.netwrote in message
news:O8**************@TK2MSFTNGP03.phx.gbl...
Yes, here's an example that allows upload and download of files and binary
storage of them in SQL Server.
http://SteveOrr.net/articles/EasyUploads.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net

"david" <da***@discussions.microsoft.comwrote in message
news:E1**********************************@microsof t.com...
I remember that there are functions to do it, but I forgot their names.

Anyone can give me a help?

Thank you.

David


Jul 7 '06 #5

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

Similar topics

2
by: forums_mp | last post by:
I've got an STL class (see below) with two functions to store and retrieve data - msg structs. The "Store" function when called will copy the received message (depending on which message) into...
5
by: Roy Gourgi | last post by:
Hi, I am used to working in Visual FoxPro and I would like to be able to create a database and store and retrieve information from it. What is the simplest way to do it and what should I be...
5
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...
3
by: piotrek | last post by:
Hi I would like to ask you a question. Ian creating app. that download from server directory structure ( whole tree ) and those data are placed in proper places into my treeview control. I...
5
by: jc | last post by:
Hi. I am in a situation with an engineering application involving monitoring of press operations. This involves storage of numbers for both an X and Y arrays. The number of element within the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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
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
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,...

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.