Question How to Save CSV & Text File to Image Field in SQL table?

lovepanda

Member
Joined
Apr 26, 2011
Messages
6
Programming Experience
1-3
Hi all,
urgently need help on how to store CSV & Text file to an Image Field in SQL table.
the table is using by some other application that's why i could not change the field data type.
currently already have a program to grab data from this 'image' field and populate it as an email attachment.
so what i need to do is to fill in the 'image' field with my Csv/Text file data so that the program able to create attachment with it.
any ideas?
 
Are you saying that you want to save the contents of multiple files to one field or will it always be just one file?

Regardless, you can get the binary contents of the file as a Byte array by calling IO.File.ReadAllBytes. If you're only saving one file then that's it. That Byte array is what you save to the database, just like any other data. If you want to save multiple files then you need to combine multiple Byte arrays into one in some way that allows you to separate them again afterwards. If that's what you need then provide us with full and clear details and we can provide a solution.
 
Hi,
thanks a lot for your reply. :)
the CSV/text file will be generated before calling this function to save the file data into database column.
there is always just 1 single file (either CSV/text file) to be converted and saved into that image column.
is there any different converting CSV or text file to byte array?
appreciate if you can provide a simple example. ^^
 
A CSV file contains plain text so it's just a text file in a specific format. Regardless there's difference to getting a Byte array from a file regardless of the file type. Binary data is binary data.
 
Back
Top