- add a data table in this data set.
- add column that you want to show your report.
- go to picture/image type data column properties.
- change data type to System.Byte[].
2. add a crystal report, go expert data source , show the data table.
- design your report... give the picture field...in your crystal report.
3. Add a form than add a crystal report viewer. then write the following code in form load section.
CrystalReport1 objRpt;
private void Form1_Load(object
sender, EventArgs e)
{
objRpt = new
CrystalReport1();3
string connString = "Server=ServerName;Database=DataBase;User
ID=UserID;Password=Password;";
string query = "Write
Your Query";
using (SqlConnection
Conn = new SqlConnection(connString))
{
SqlDataAdapter adepter = new
SqlDataAdapter(query, connString);
DataSet DS = new DataSet();
DataTable DT = new
DataTable("DataTable1");
//DataTable
name must mach with Step1 Data table
adepter.Fill(DS);
DT = DS.Tables[0];
objRpt.SetDataSource(DT);
crystalReportViewer1.ReportSource =
objRpt;
}
}
and then just run your project........and enjoy it!!!!!!!!!!!!!!!!!!!!!
If this post is help you.......comment please......................
This is a great post.Carry on
ReplyDelete