Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Inserting BLOB data
Message
De
18/10/2011 07:50:07
 
 
À
17/10/2011 17:30:09
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2008
Divers
Thread ID:
01526493
Message ID:
01526747
Vues:
41
Thanks Bill!

>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.
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform