R
Rob Nicholson
We need to update an image stored in a SQL server. I understand that the
basic code *could* go something like:
BEGIN
Load the image from the file into a byte array
Create a SqlConnection
Create a SqlCommand and specify the command text as "Update [People] Set
[Photo]=@Photo Where [PersonID]=2"
Add a parameter to the command for @Photo declared at SqlBinary and using
the byte array as the data source
Fire off a ExecuteNonQuery
END
The question is, for SqlBinary data type, does ADO.NET in effect convert the
entire byte array into a very long hex string and in effect, something like
the following is passed to the SQL Server:
Update [People] Set
[Photo]=0x56856856856856985968596895865656563ABCD4545DFEA8884 (etc) Where
[PersonID]=2
If so, I guess this method should only be used for relatively small files?
Does the same happen on loading as well as when you dig into a data reader
or data set, the column is a byte array.
Cheers, Rob.
basic code *could* go something like:
BEGIN
Load the image from the file into a byte array
Create a SqlConnection
Create a SqlCommand and specify the command text as "Update [People] Set
[Photo]=@Photo Where [PersonID]=2"
Add a parameter to the command for @Photo declared at SqlBinary and using
the byte array as the data source
Fire off a ExecuteNonQuery
END
The question is, for SqlBinary data type, does ADO.NET in effect convert the
entire byte array into a very long hex string and in effect, something like
the following is passed to the SQL Server:
Update [People] Set
[Photo]=0x56856856856856985968596895865656563ABCD4545DFEA8884 (etc) Where
[PersonID]=2
If so, I guess this method should only be used for relatively small files?
Does the same happen on loading as well as when you dig into a data reader
or data set, the column is a byte array.
Cheers, Rob.