Retreiving SQL Image data

I have made a web page in Visual Studio 2005 to take information and an uploaded file and place the data in a SQL 2000 Server. The file (Word, Excel, or PDF) is placed in an image data type. The problem is How do I create another web page that allows this file to be downloaded to their computer

Answer this question

Retreiving SQL Image data

  • Singing in the Rain

    Hi

    Can you please describe the problem you are facing more clearly as i am unable to understand what you are trying to do.Do you want to give the option to download the documents in a separate page

    Thanks,

    Arabinda



  • James HSia

    You can retrive the data(Image type) from the table and store it in Byte array.While opening the file convert it to filestream.It will convert it to the original file what ever may be the type(doc/pdf/jpeg)

    --Arabinda



  • vinod-stylus

    I have a web form that is placing the data into SQL using the following code:

    Dim origFileData(CInt(Example.Length - 1)) As Byte

    Example.Read(origFileData, 0, CInt(Example.Length))

    Dim connection As New SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionString1").ConnectionString)

    Dim command As New SqlCommand("INSERT INTO PTISWR (RDate, Plant, Requester, RNature, Part, Department, Type, RImportance, RCompletion_Date, Details, Example) VALUES ( @Date, @Plant, @Requester, @Nature, @Part, @Department, @Type, @RImportance, @RCompletion_Date, @Details, @Example);", connection)

    Dim param0 As New SqlParameter("@Date", System.Data.SqlDbType.DateTime)

    param0.Value = dtToday

    command.Parameters.Add(param0)

    Dim param1 As New SqlParameter("@Plant", System.Data.SqlDbType.Char, 50)

    param1.Value = strPlant

    command.Parameters.Add(param1)

    Dim param2 As New SqlParameter("@Requester", System.Data.SqlDbType.Char, 50)

    param2.Value = strRequester

    command.Parameters.Add(param2)

    Dim param3 As New SqlParameter("@Nature", System.Data.SqlDbType.Char, 50)

    param3.Value = strNature

    command.Parameters.Add(param3)

    Dim param4 As New SqlParameter("@Part", System.Data.SqlDbType.Char, 50)

    param4.Value = strPart

    command.Parameters.Add(param4)

    Dim param5 As New SqlParameter("@Department", System.Data.SqlDbType.Char, 50)

    param5.Value = strDepartment

    command.Parameters.Add(param5)

    Dim param6 As New SqlParameter("@Type", System.Data.SqlDbType.Char, 50)

    param6.Value = strType

    command.Parameters.Add(param6)

    Dim param7 As New SqlParameter("@RImportance", System.Data.SqlDbType.Char, 50)

    param7.Value = strLevel

    command.Parameters.Add(param7)

    Dim param8 As New SqlParameter("@RCompletion_Date", System.Data.SqlDbType.DateTime)

    param8.Value = dtRequestFinish

    command.Parameters.Add(param8)

    Dim param9 As New SqlParameter("@Details", System.Data.SqlDbType.Text)

    param9.Value = txtDetails

    command.Parameters.Add(param9)

    Dim param10 As New SqlParameter("@Example", System.Data.SqlDbType.Image)

    param10.Value = origFileData

    command.Parameters.Add(param10)

    connection.Open()

    Dim intcount = command.ExecuteNonQuery()

    connection.Close()

    This works. I now have a SQL table with the data from the web form and param10 is a file that is being placed in SQL in a data type image.

    The problem is a cannot get the file out of SQL. I would like to make another (NEW) web page that allows the veiwer to edit/delete the records in the SQL table. And if they choose to, copy the file loaded into SQL to their local computer to see the file that was loaded into SQL. I have no problem showing the string, text, and date values in this "New" web page and setting it up for editing and deleting. I don't know how to get at the file loaded into SQL.

    Thanks,


  • Retreiving SQL Image data