Click here to Skip to main content
15,917,618 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
DataTable dt = new DataTable();
DataRow drow;
dt.Columns.Add("Image", System.Type.GetType("System.Byte[]"));
drow = dt.NewRow();
FileStream fs;
BinaryReader br;
fs = new FileStream(@"D:\avatar1.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);
// dt.Rows.Add(imgbyte);
//br.Close();
//fs.Close();
mycrystal crp = new mycrystal();
crp.SetDataSource(dt);//<-------------Gettig Error Here...
crystalReportViewer1.ReportSource = crp;




Please Help..
Posted
Updated 5-Sep-13 2:24am
v2
Comments
Mayur Panchal 5-Sep-13 9:08am    
I am not sure but try below line of code, after defining table 'dt'.
dt.TableName = "Table1";

Let me know, if it works.

1 solution

Agree with Mayur Panchal. You should give name for that datatable.
Make sure the table names are same on both report & code. Open that report, check the Table name in Field explorer. And give the same name to the datatable in code.
FYI
The report has no tables. ? [RESOLVED][^]
The report has no tables[^]
 
Share this answer
 

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