| Here is the code to print picture in crystal report |
Sujit Patil provided a rated reply to Atheeq Ahmed on Monday, June 16, 2008 1:06 AM |
|
Just create a temp table add a oleObject(bolb field) place the image u want to show in report after report generation delete that file I am sending code in which i used chunck table to show the picture
i mapped that feild in report.
Public Sub SaveReportPicture(rtfOrig As RichTextBox, rtfUser As RichTextBox, ParamFaultid As Byte, Optional flag As Boolean, Optional lstfile As ListBox) Dim fso As New FileSystemObject Dim newconnect As String newconnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sFile & ";Persist Security Info=False;Jet OLEDB:Database Password=" & CStr(G_Password) Dim repcn As ADODB.Connection Set repcn = New ADODB.Connection repcn.Open newconnect Dim mstream As ADODB.Stream Dim Index As Byte, PictureName As String Dim RsPic As New ADODB.Recordset 'for opening recordset Cn.Execute "Delete from Chunks "
RsPic.Open "Select test_definition_id,FAULT_TYPE,photo,Under_Over_Type from chunks", repcn, adOpenKeyset, adLockOptimistic If flag = False Then For Index = 0 To ParamFaultid PictureName = ReportDefinitionID & Index & ".jpg" If fso.FileExists(DBnameFolder & "\" & PictureName) Then Set mstream = New ADODB.Stream mstream.Type = adTypeBinary mstream.Open mstream.LoadFromFile DBnameFolder & "\" & PictureName
RsPic.AddNew RsPic.Fields("photo").Value = mstream.Read RsPic.Fields(0) = ReportDefinitionID RsPic("Fault_Type") = Index RsPic("under_over_type") = 0 RsPic.Update mstream.Flush mstream.Close Set mstream = Nothing End If Next End If If flag = True Then
For Index = 0 To 1 PictureName = ReportDefinitionID & Index & ".jpg" If fso.FileExists(DBnameFolder & "\" & PictureName) Then Set mstream = New ADODB.Stream mstream.Type = adTypeBinary mstream.Open mstream.LoadFromFile DBnameFolder & "\" & PictureName RsPic.AddNew RsPic.Fields("photo").Value = mstream.Read RsPic.Fields(0) = ReportDefinitionID RsPic("Fault_Type") = 0 RsPic("under_over_type") = Index RsPic.Update mstream.Flush mstream.Close Set mstream = Nothing End If Next
End If
Err.CLEAR rtfOrig.text = "" rtfUser.text = "" repcn.Execute "delete from Chunks_TestDefinition_NoteBook" rsrelaynotebook.Close Set rsrelaynotebook = Nothing Set rsrelaynotebook = New ADODB.Recordset rsrelaynotebook.Open "select * from Chunks_TestDefinition_NoteBook", repcn, adOpenDynamic, adLockOptimistic If fso.FileExists(DBNoteBookFolder & "\" & "TD_O" & ReportDefinitionID & ".rtf") Then rtfOrig.LoadFile DBNoteBookFolder & "\" & "TD_O" & ReportDefinitionID & ".rtf" End If
If fso.FileExists(DBNoteBookFolder & "\" & "TD_U" & ReportDefinitionID & ".rtf") Then rtfUser.LoadFile DBNoteBookFolder & "\" & "TD_U" & ReportDefinitionID & ".rtf" End If rsrelaynotebook.AddNew rsrelaynotebook(0) = ReportDefinitionID rsrelaynotebook(2) = rtfOrig.text rsrelaynotebook(1) = rtfUser.text rsrelaynotebook(3) = Tattached_files rsrelaynotebook.Update repcn.Close Set repcn = Nothing Set fso = Nothing Set rsrelaynotebook = Nothing End Sub
Just go thr this link for more details;
http://visualbasic.ittoolbox.com/groups/technical-functional/vb-crystalreports-l/printing-pictures-in-crystal-reports-80-247818#
http://www.tech-archive.net/Archive/VB/microsoft.public.vb.crystal/2006-08/msg00136.html
Here are some links realated to crystal report just go thr this;
http://www.codeguru.com/forum/archive/index.php/f-64-p-9.html
Best Luck!!!!!!!!!!!!!! Sujit.
|
| Reply Reply Using Power Editor |
| |
| |
Rank |
Winnings |
Points |
| November |
27 |
$0.00 |
7 |
| October |
9 |
$30.00 |
102 |
|
|
|
|
|
|
| Binary format |
sri sri provided a rated reply to Atheeq Ahmed on Monday, June 16, 2008 1:31 AM |
|
Hi, you have to convert your image file to binary format and you have to pass to the crystal report. try the below code
DataTable dt = new DataTable();
DataRow drow; // add the column in table to store the image of Byte array type
dt.Columns.Add("Image", System.Type.GetType("System.Byte[]")); drow = dt.NewRow; FileStream fs; BinaryReader br;
if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "1.Jpg")) { // open image in file stream
fs = new FileStream(AppDomain.CurrentDomain.BaseDirectory + "1.Jpg", FileMode.Open); } else { // if phot does not exist show the nophoto.jpg file
fs = new FileStream(AppDomain.CurrentDomain.BaseDirectory + "NoImage.jpg", FileMode.Open); }
br = new BinaryReader(fs); byte[] imgbyte = new byte[fs.Length + 1]; imgbyte = br.ReadBytes(Convert.ToInt32((fs.Length))); drow(0) = imgbyte;
dt.Rows.Add(drow); br.Close(); fs.Close(); CrystalReport1 rptobj = new CrystalReport1(); rptobj.SetDataSource(dt); CrystalReportViewer1.ReportSource = rptobj;
|
| Reply Reply Using Power Editor |
| |
| |
Rank |
Winnings |
Points |
| November |
29 |
$0.00 |
6 |
| October |
0 |
$0.00 |
0 |
|
|
|
|
|
|
| How to print Picture in Crystal Report 8.5 |
Swapnil Salunke provided a rated reply to Atheeq Ahmed on Monday, June 16, 2008 1:35 AM |
|
Hello Atheeq Ahmed
You can try this way try { DataTable dt = new DataTable(); DataRow drow; dt.Columns.Add("Image", System.Type.GetType("System.Byte[]")); drow = dt.NewRow; FileStream fs; BinaryReader br; if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "10157.Jpg")) { fs = new FileStream(AppDomain.CurrentDomain.BaseDirectory + "10157.Jpg", FileMode.Open); } else { fs = new FileStream(AppDomain.CurrentDomain.BaseDirectory + "NoPhoto.jpg", FileMode.Open); } br = new BinaryReader(fs); byte[] imgbyte = new byte[fs.Length + 1]; imgbyte = br.ReadBytes(Convert.ToInt32((fs.Length))); drow(0) = imgbyte; dt.Rows.Add(drow); br.Close(); fs.Close(); CrystalReport1 rptobj = new CrystalReport1(); rptobj.SetDataSource(dt); CrystalReportViewer1.ReportSource = rptobj; } catch (Exception ex) { Interaction.MsgBox("Missing 10157.jpg or nophoto.jpg in application folder"); }
|
| Reply Reply Using Power Editor |
| |
| |
Rank |
Winnings |
Points |
| November |
0 |
$0.00 |
0 |
| October |
0 |
$0.00 |
0 |
|
|
|
|
|
|
|
|
|
|
| re: |
alice johnson provided a rated reply to Atheeq Ahmed on Monday, June 16, 2008 12:00 PM |
|
i mapped that feild in report.
Public Sub SaveReportPicture(rtfOrig As RichTextBox, rtfUser As RichTextBox, ParamFaultid As Byte, Optional flag As Boolean, Optional lstfile As ListBox) Dim fso As New FileSystemObject Dim newconnect As String newconnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sFile & ";Persist Security Info=False;Jet OLEDB:Database Password=" & CStr(G_Password) Dim repcn As ADODB.Connection Set repcn = New ADODB.Connection repcn.Open newconnect Dim mstream As ADODB.Stream Dim Index As Byte, PictureName As String Dim RsPic As New ADODB.Recordset 'for opening recordset Cn.Execute "Delete from Chunks "
RsPic.Open "Select test_definition_id,FAULT_TYPE,photo,Under_Over_Type from chunks", repcn, adOpenKeyset, adLockOptimistic If flag = False Then For Index = 0 To ParamFaultid PictureName = ReportDefinitionID & Index & ".jpg" If fso.FileExists(DBnameFolder & "\" & PictureName) Then Set mstream = New ADODB.Stream mstream.Type = adTypeBinary mstream.Open mstream.LoadFromFile DBnameFolder & "\" & PictureName
RsPic.AddNew RsPic.Fields("photo").Value = mstream.Read RsPic.Fields(0) = ReportDefinitionID RsPic("Fault_Type") = Index RsPic("under_over_type") = 0 RsPic.Update mstream.Flush mstream.Close Set mstream = Nothing End If Next End If If flag = True Then
For Index = 0 To 1 PictureName = ReportDefinitionID & Index & ".jpg" If fso.FileExists(DBnameFolder & "\" & PictureName) Then Set mstream = New ADODB.Stream mstream.Type = adTypeBinary mstream.Open mstream.LoadFromFile DBnameFolder & "\" & PictureName RsPic.AddNew RsPic.Fields("photo").Value = mstream.Read RsPic.Fields(0) = ReportDefinitionID RsPic("Fault_Type") = 0 RsPic("under_over_type") = Index RsPic.Update mstream.Flush mstream.Close Set mstream = Nothing End If Next
End If
Err.CLEAR rtfOrig.text = "" rtfUser.text = "" repcn.Execute "delete from Chunks_TestDefinition_NoteBook" rsrelaynotebook.Close Set rsrelaynotebook = Nothing Set rsrelaynotebook = New ADODB.Recordset rsrelaynotebook.Open "select * from Chunks_TestDefinition_NoteBook", repcn, adOpenDynamic, adLockOptimistic If fso.FileExists(DBNoteBookFolder & "\" & "TD_O" & ReportDefinitionID & ".rtf") Then rtfOrig.LoadFile DBNoteBookFolder & "\" & "TD_O" & ReportDefinitionID & ".rtf" End If
If fso.FileExists(DBNoteBookFolder & "\" & "TD_U" & ReportDefinitionID & ".rtf") Then rtfUser.LoadFile DBNoteBookFolder & "\" & "TD_U" & ReportDefinitionID & ".rtf" End If rsrelaynotebook.AddNew rsrelaynotebook(0) = ReportDefinitionID rsrelaynotebook(2) = rtfOrig.text rsrelaynotebook(1) = rtfUser.text rsrelaynotebook(3) = Tattached_files rsrelaynotebook.Update repcn.Close Set repcn = Nothing Set fso = Nothing Set rsrelaynotebook = Nothing End Sub |
| Reply Reply Using Power Editor |
| |
| |
Rank |
Winnings |
Points |
| November |
0 |
$0.00 |
0 |
| October |
0 |
$0.00 |
0 |
|
|
|
|
|
|
| I need this coding in vb.net - Picture print in crystal rep 8,5 |
| Atheeq Ahmed replied to sri sri on Wednesday, June 18, 2008 1:38 AM |
|
Dear senthil kumar
Thanks for sending me coding for picture printing in crystal report
Can you please send me in vb.net format.
I already hv a picture path in my table similar to this the photo can be print in Crystal report.
Pls help
Atheeq
|
| Reply Reply Using Power Editor |
| |
| |
Rank |
Winnings |
Points |
| November |
0 |
$0.00 |
0 |
| October |
0 |
$0.00 |
0 |
|
|
|
|
|
|
| Please help how to print picture in Crystal Report 8.5 from the given path |
| GULAM SHAIKH replied to Atheeq Ahmed on Monday, July 27, 2009 1:13 AM |
|
D:\foto\george.jpg |
| Reply Reply Using Power Editor |
| |
| |
Rank |
Winnings |
Points |
| November |
0 |
$0.00 |
0 |
| October |
0 |
$0.00 |
0 |
|
|
|
|
|
|
|