Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Saving images, etc. to SQL Server Column
Message
De
04/08/2004 12:24:17
Bill Benton
North Florida Software Services
Middleburg, Floride, États-Unis
 
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Divers
Thread ID:
00923304
Message ID:
00930685
Vues:
19
Carl,

I finally fingered it out.

"dsItems.Tables[0].Rows[0]["ItemPhoto"]" is the syntax for C#.

I was using a binary data column in SQL, and was getting errors (truncation). I finally realized that it had to be stored into an image column.

Would you possibly have the code to restore and view the stored images?



>Bill, you can do something like this (pardon the VB.NET code but it should be easy to translate):
>
>
>If UploadImage.PostedFile Is Nothing Then
>   'Nothing to upload
>Else
>   'Upload the image file
>   Dim mItemPhotoStream As New MemoryStream
>   Dim imageStream As Stream = UploadImage.PostedFile.InputStream
>   Dim imageName As String
>   imageName = Path.GetFileName(UploadImage.PostedFile.FileName)
>   Dim imageData(1024) As Byte
>   Dim count As Integer = imageData.Length
>   count = imageStream.Read(imageData, 0, imageData.Length)
>   Do While count > 0
>      mItemPhotoStream.Write(imageData, 0, count)
>      count = imageStream.Read(imageData, 0, imageData.Length)
>   Loop
>
>   'Update Item Photo column in the dataset
>   If mItemPhotoStream.Length > 0 Then
>      dsItem.Tables(0).Rows(0).Item("ItemPhoto") = mItemPhotoStream.GetBuffer()
>   Else
>      dsItem.Tables(0).Rows(0).Item("ItemPhoto") = DBNull.Value
>   End If
>End If
>
>
>>I am trying to save items (attachments and such(.DOC, .XLS, etc.)) into a SQL table. I am using an image column, and haven't had much luck saving the files into an image column.
>>
>>I have implemented "Upload" functionality that will return the path, but that is far cry from storing the actual file into a SQL Column.
>>
>>Any assistance would be greatly appreciated!
>>
>>I am using C#, with MM Framework.
>>
>>Thanks in advance
Bill Benton
Senior Systems Analyst
Nuvell Financial Services
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform