Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Saving images, etc. to SQL Server Column
Message
De
04/08/2004 08:15:23
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:
00930615
Vues:
21
>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

I am finally trying to implement the above code. I have converted it to C# using a third-party utility, but it keeps crashing on:
dsItem.Tables(0).Rows(0).Item("ItemPhoto")

It seems that C# doesn.t want to recognize the .item() in "dsItem.Tables(0).Rows(0).Item(". It seems that that method is not available.

Do you have any ideas?
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