hah the code is right in front of me, it's also in a current project....
so i have a table that has a column named bytes of type image.
in sql there is an update statement that looks plain ordnary update xxx set bytes = @paramname
where ....
in .net i take the data from a stream or from a file and use a memory stream.
like this:
public static byte[] FileToBytes(string FileName)
{
FileInfo f = new FileInfo(FileName);
FileStream stream = f.OpenRead();
byte[] buffer = new byte[stream.Length];
stream.Read(buffer, 0, (int)stream.Length);
stream.Close();
stream.Dispose();
stream = null;
f = null;
return buffer;
}
the byte array then becomes a param to a sql statement.
reverse the logic to pull it back out.
i suspect that .net handles some details of how this data gets tranfered due to the use of parameters
the c# param is just a simple:
now to see if this can be read.. after c9 mangels it.
using (SqlCommand command = new SqlCommand(strProcedureName, connection)) {
command.CommandType = CommandType.StoredProcedure;
...
command.Parameters.Add(new SqlParameter("@Bytes", Bytes));
command.Parameters.Add(new SqlParameter("@MimeType", MimeType));
connection.Open();
command.ExecuteNonQuery();
}