I found this syntax on the web and it works nicely:
filepath is the full path of the file to be put in the blob.
imageds.imagedocuments is a datatable in a strongly typed dataset that is used to update the
SQL Sever table
string filename = Path.GetFileName(filepath);
DateTime currentdate = DateTime.Now;
FileStream fs = new FileStream(filepath, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fs);
byte[] blobdata = br.ReadBytes((int)fs.Length);
br.Close();
fs.Close();
imageds.imagedocuments[0].filename = filename;
imageds.imagedocuments[0].docgroup = docgroup;
imageds.imagedocuments[0].blobdata = blobdata;
>
I found this code and I've tried this before on my setup and I got it to work in a test environment.
>
>Now, the project is moving forward.
>
>However, it occurred to me that on my test setup, the C: drive of the SQL Server and the C: drive of where the file resides are the same.
>
>That will not be true in the production world.
>The file will be on the C: drive of the client W/S.
>Is that an issue or am I conjuring up non-existing issues (again)?
>
>If is an issue, how to handle it?
>
>
>
>INSERT Production.ProductPhoto (
> ThumbnailPhoto,
> ThumbnailPhotoFilePath,
> LargePhoto,
> LargePhotoFilePath)
>SELECT ThumbnailPhoto.*, null, null, N'tricycle_pink.gif'
>FROM OPENROWSET
> (BULK 'c:\images\tricycle.jpg', SINGLE_BLOB) ThumbnailPhoto
>
I got around it by copying the file from the user's hard drive to a shared folder that the server has access to, then doing the bulk upload, then deleting the file from the shared folder.
Anyone who does not go overboard- deserves to.
Malcolm Forbes, Sr.