Multiple Image Load | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Multiple Image Load

How can I upload several pictures at once to use in a SQL Report? There are over 6,000 pictures that I need available for a form letter that will include a picture of the product referenced in the letter. If I can load all of them at once into the project and reference them by name connected from a stored procedure to the name of the picture, that would be fine. Someone on another board it was suggested I store the source in a SQL database, but it hasn’t worked when I try it that way. I would send the report the link and have it get the picture at the time of deployment if that would be what is most helpful. Joe Janka
If the picture is small (say 10Kb or so), its better you store it to database as Image with an ImageID. Write an SP to retrieve the required Images.
You can drag multiple images on the Report
If you want them to be displayed Row-wise
–Drag a Table
–Drag Image to one of the Details Column. It will open Image Dialog where you can specify the location of the image as one of the dataset fields. If you want them to be displayed Column-wise
–Do the same procedure in a Matrix, Row group by some static field HTH Harsh
in case anyone runs into this problem, this is how the problem was solved on my end, i made an ASP.NET windows form and put a button with the following code in it:
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click For Each File As String In Directory.GetFiles("C:FilePathIMAGES")
Dim cn As New SqlConnection(strCn)
Dim cmd As New SqlCommand("INSERT INTO <<TABLE NAME>> (PIC_NAME, PICTURE) " & _
"VALUES (@ID, @BLOBData)", cn)
Dim strBLOBFilePath As String = File
Dim strID As String = RTrim(Mid(File, 15, 12))
Dim fsBLOBFile As New FileStream(strBLOBFilePath, _
FileMode.Open, FileAccess.Read)
Dim bytBLOBData(fsBLOBFile.Length() – 1) As Byte
fsBLOBFile.Read(bytBLOBData, 0, bytBLOBData.Length)
fsBLOBFile.Close()
Dim prm As New SqlParameter("@BLOBData", SqlDbType.VarBinary, _
bytBLOBData.Length, ParameterDirection.Input, False, _
0, 0, Nothing, DataRowVersion.Current, bytBLOBData)
cmd.Parameters.Add(prm)
Dim prm2 As New SqlParameter("@ID", SqlDbType.VarChar, 50, ParameterDirection.Input, False, 0, 0, Nothing, DataRowVersion.Current, strID)
cmd.Parameters.Add(prm2)
cn.Open()
cmd.ExecuteNonQuery()
cn.Close()
Next File End Sub Joe Janka
]]>