Click here to Skip to main content
15,883,705 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi I want to dispaly image in Crystal Report From Folder Based on Imagepath from Database.
I am using Vb.net
Thank You
Posted
Updated 9-May-16 7:35am

SQL
str="select distinct code,designname from table1 left join table2 on table1.code=table2.code"
cmd = New SqlCommand(Str, sqlconn)
      adpt = New SqlDataAdapter(cmd)
      DataSetDesign = New DataSet
      DataSetDesign.Clear()
      adpt.Fill(DataSetDesign, "MYtable")


Create a new table "Pic"
Field : DSG_CODE,varchar(15)
        oImg,varbinary(MAX)


        Dim iCtr As Integer
            Dim cPict, cCat, cDesCode, SqlStr As String

            SqlStr = "Delete From pict"

            Dim cmdInsert As SqlCommand
            cmdInsert = New SqlCommand(SqlStr, sqlconn)
            cmdInsert.ExecuteNonQuery()

            For iCtr = 0 To DataSetDesign.Tables(0).Rows.Count - 1
                cCat = Trim(DataSetDesign.Tables(0).Rows(iCtr).Item("designname"))
                cDesCode = Trim(DataSetDesign.Tables(0).Rows(iCtr).Item("code"))

                'Path of Folder
                cPict = "y:\" + cCat + "\DM 3D " + cDesCode + ".JPG"

                    Dim oImg As Byte()
                    oImg = ReadImageFile(cPict)
                    SqlStr = "Insert Into pict(oImg, DSG_Code)values(@oImg , @DSG_Code)"
                    cmdInsert = New SqlCommand(SqlStr, sqlconn)
                    'cmdInsert(Sqlstr, sqlconn)
                    cmdInsert.Parameters.Add("@oImg", Data.SqlDbType.Binary).Value = oImg
                    cmdInsert.Parameters.Add("@DSG_CODE", Data.SqlDbType.VarChar).Value = cDesCode
                    cmdInsert.ExecuteNonQuery()
      Next
 
Share this answer
 
Comments
ghulam murtaza bajwa 30-Aug-21 3:49am    
Hi I want to dispaly image in Crystal Report 8.5 From Folder Based on Imagepath from Database.
I am using Vb.6
Thank You
Don't use physical paths with CR directly. Store your image in a datatable or in a binary field of your database and show that.

Here is a code project solution that uses datatables:

Image in Crystal Reports

It's simple, C# and a little old, but I think you get the trick.

[Agent_Spock]
Removed unwanted code brackets
 
Share this answer
 
v2
Comments
Member 9799439 2-Feb-13 0:27am    
Thank you.but i am using crystal report 9 and in that insert picture object -> select format graphic -> then select picture tab.. here 'graphic location ' option not showing.
what to do now..?
Member 9799439 5-Feb-13 1:21am    
Hey Hi VG
I executed the code that you mentioned above but the same did not get executed.
Hi,
Put an image field in your report, then change the image’s Graphic Location:
right click the image, select Format Graphic, select Picture tab, click the conditional-formula button that look like a x2 and set the formula’s text to the name of the formula or parameter field that will contain the image’s URL.
Save the formula and click the OK button. Save the report and test it.
Be carefull with the size of the image field. If this size is not equal to the image itself it could get resized.

Googled from http://stackoverflow.com/questions/3170387/display-image-in-crystal-report-using-physical-path[^]

Best Regards,
VG
 
Share this answer
 
v2
Comments
agent_kruger 1-Apr-14 0:38am    
sir, can you provide image as i cant see image’s Graphic Location option.
_Vitor Garcia_ 1-Apr-14 6:24am    
To change the image's graphic location follow these steps :

right click the image, select Format Graphic, select Picture tab, click the conditional-formula button that look like a x2 and set the formula’s text to the name of the formula or parameter field that will contain the image’s URL.
Save the formula and click the OK button. Save the report and test it.
_Vitor Garcia_ 1-Apr-14 6:36am    
Here it is :
This is after you right click the image, select Format Graphic and select Picture tab
http://s4.postimg.org/eoa31sf19/Graphics_Location.jpg

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900