-
1 KB images
Hi guys,
I have a problem and it has been 3 hours and a half and I haven't successfully created a file from the database. It always generate a 1KB file.
How can I successfully create the image file from the database.
Here's my code for saving the image in the database.
Code:
Dim b As New IO.FileStream(Web.Configuration.WebConfigurationManager. _
AppSettings("EmpPhotos") & "Ratonel JB.jpg", IO.FileMode.Open)
Dim a(b.Length) As Byte
fupPicture.PostedFile.InputStream.Read(a, 0, b.Length)
ADOCmd.Parameters(21).Value = a
b.Close()
ADOCmd.Parameters(22).Value = Session("PhotoPath")
ADOCmd.Connection = ADOConn
ADOCmd.CommandType = CommandType.StoredProcedure
ADOCmd.CommandText = "GenerateEmployee"
ADOCmd.ExecuteNonQuery()
And here's my code for loadin the image from the database to a file.
Code:
Global_asax.ADOCmd.Connection = Global_asax.ADOConn
Global_asax.ADOCmd.CommandType = CommandType.StoredProcedure
Global_asax.ADOCmd.CommandText = "LocateEmpPhoto"
'Global_asax.ADODA.SelectCommand = Global_asax.ADOCmd
'Global_asax.ADODataset.Reset()
'Global_asax.ADODA.Fill(Global_asax.ADODataset)
'PhotoPath = Global_asax.ADODataset.Tables(0).Rows(0).Item(1)
If IO.File.Exists(Web.Configuration.WebConfigurationManager.AppSettings("EmpPhotos") _
& PhotoPath) Then
Else
Dim PhotoFile As New IO.FileStream(Web.Configuration.WebConfigurationManager. _
AppSettings("EmpPhotos") & "Test", IO.FileMode.CreateNew)
Dim a As SqlClient.SqlDataReader = Global_asax.ADOCmd.ExecuteReader
Dim PhotoWriter As New IO.BinaryWriter(PhotoFile)
If a.Read Then
PhotoWriter.Write(a("Photo"))
End If
PhotoWriter.Close()
PhotoFile.Close()
End If
Cheers,
Thomas Grayson
-
Re: 1 KB images
If the image is the same size each time, then it's likely an error. Change the extension of the image to txt or html and look at it in a text-viewer or browser.
There's probably the HTML of an error message in there.