First create a class file any time we can call to create a crystal report:-
ReportGenerate.cs
public ReportDocument ReportEngine(string sqlstat,string Reportpath)
{
ReportDocument obj=new ReportDocument();
Dataset ds=new Dataset();
SqlDataAdapter da=new SqlDataAdapter(sqlstat,connection);
da.fill(ds);
obj.Load(Reportpath);
obj.setDataSource(ds.tables[0]);
return obj;
}
Take a crystal Report viewer:-
using crystal Decissions.CrystalReport.Engine;
ReportGenerate obj=new ReportGenerate();
CrystalReportViewer1.Reportsource=obj.ReportEngine("select the query whatever u want","Reportpath");
CrystalReportViewer1.DataBind();
Crystal Report Beginner follow the video file
http://www.youtube.com/watch?v=VmlqphNEpz0
How can you bind datain dataset to crystal Report?
SqlConnection connection = new SqlConnection("server='SERVER-NAME';uid= 'USER-ID'; "pwd='PASSWORD';database=DATABASE_NAME; Connect Timeout=1000000");
connection.Open();
string selectQry = "YOUR-SQL-QUERY-HERE";
DataSet myDS = new DataSet();
SqlDataAdapter myDataAdapter = new SqlDataAdapter(selectQry, connection);
myDataAdapter.Fill(myDS, "InfoTable");
myReportDocument.Load(@Server.MapPath("myCrystalReport.rpt"));
myReportDocument.SetDataSource(myDS);
CrystalReportViewer1.ReportSource = myReportDocument;
CrystalReportViewer1.DataBind();
otherwise you follow the below mentioned url :
No comments:
Post a Comment