I have a client who is asking me to import jpeg files into their SQL Server database.
The problem is that their database vendor originally build the product in SQL Server 2000 (or earlier) although their database currently sits on a SQL Server 2008 R2 instance. It appears that their old data looks like it's just being dumped into a big field of datatype text
.
Is it possible to read the jpeg file into a MemoryStream
then write that directly to the SQL Server database? If so, how would I go about doing this? Or, is there a better way?
Thanks,
Andre
I suppose if you really needed to do this, you can build the byte-stream into a string like this:
MemoryStream ms = [your stream];
Byte[] memoryBytes = ms.ToArray();
StringBuilder sBuilder = new StringBuilder();
foreach(byte nextByte in memoryBytes)
sBuilder.Append((char)nextByte);
string res = sBuilder.ToString();
Then store it in the database by passing the string. You should try and get some extra work out of your client by offering to update their database structure though ;)