如何使用水晶报表数据库使用代码. [英] How can use crystal report database using code.
问题描述
我首先将数据库XSd文件用于所有Crystal报表,并与数据库绑定.现在我可以直接访问数据库,这意味着在创建水晶报表的同时选择OLEDB(sqlserver)并浏览数据库文件.
出于条件目的,直接使用选择公式.然后晶体报告显示所需的输出.
但是使用服务器-客户端应用程序效率不高.
使用另一台计算机时必须设置每个报告源.
我需要使用sqlquery.query输出数据集设置为报表的报告源,将数据公开给Crystal报表.
为此
数据(菜单)->添加新数据源->数据库->下一步->新建连接->选择数据库->下一步->滴答表,数据集的存储过程->完成
代码如下
I am first in using a database XSd file for all crystal reports,bind with database. Now I can access database directly ,means when crate a crystal report same time select OLEDB(sqlserver) and browse database file.
For condition purpose direct use selection formula.Then crystal report shows desired output.
But it is not efficient for use server-clients application.
Each report source is must set when use another computer.
I need to expose data to crystal report using sqlquery.query output dataset set as reportsource of report.
For this
Data (menu)-->Add new Datasource->Database->Next->New Connection->Select Database->Next->Tick Table,Stored procedure for dataset-->Finish
Code as below
Formload()
{
CrystalReport1 rpt = new CrystalReport1();
DataSet ds=new DataSet ();
con.ConnectionString = "Data Source=GIS06;Persist Security Info=True;Password=admin1;User ID=sa;Initial Catalog=Temple";
con.Open();
sql = "select * from tbl_Name";
cmd.Connection = con;
cmd.CommandText = sql;
ada.SelectCommand = cmd;
ada.Fill(ds);
rpt.SetDataSource(ds);
crystalReportViewer1.ReportSource = rpt;
crystalReportViewer1.Show();
crystalReportViewer1.RefreshReport();
}
但是不会填充任何行.确实存在14行
But not any rows are populated. Exact 14 rows are exist
推荐答案
Dude,去年,我为您提供了类似问题的答案.
Crystal报表中没有数据. [ ^ ]
问题是您没有在报表查看器中加载报表文件.只需访问旧问题
Dude, Last year I gave you the answer for your similar question.
No Data Populate in crystal report.[^]
The thing is you didn''t loaded the report file in report viewer. Just visit the old question
这篇关于如何使用水晶报表数据库使用代码.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!