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

G

Guest

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

Anyone can give me a help?

Thank you.

David
 
S

sloan

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.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.
 
G

Guest

thanks.
Do you know any stored function to do it?

David

sloan said:
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.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 said:
I remember that there are functions to do it, but I forgot their names.

Anyone can give me a help?

Thank you.

David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top