protected CrystalDecisions.Web.CrystalReportViewer RptView;
private SqlConnection myConnection;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
myConnection=new SqlConnection("server=127.0.0.0;database=temp;user id=sa;password=123");
myConnection.Open();
string strSql="select * from user ";
SqlCommand myCommand=new SqlCommand();
myCommand.Connection=myConnection;
myCommand.CommandType=CommandType.Text;
myCommand.CommandText=strSql;
SqlDataAdapter myAd=new SqlDataAdapter();
myAd.SelectCommand=myCommand;
DataSet myDs=new DataSet();
myAd.Fill(myDs,"tbUser");
Report1 tmprpt=new Report1() ; //申明一个报表的实例 ,Report1.rpt 利用crystal report 生成
tmprpt.SetDataSource(myDs);
RptView.ReportSource=tmprpt; // CrystalReportViewer 设定 source就可以了
myCommand.Dispose();
myAd.Dispose();
myConnection.Close();
}
datatable绑定水晶报表
最新推荐文章于 2024-10-20 15:04:34 发布