Results 1 to 2 of 2

Thread: 1 KB images

  1. #1

    Thread Starter
    Hyperactive Member tommygrayson's Avatar
    Join Date
    Aug 2005
    Location
    In my Nissan Silvia
    Posts
    433

    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
    Rate Me! Rate Me! Rate Me!

    Time to fly.

    Copyright GraysonSoft Inc. 2007

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width