本文介绍了水晶报表命令中的sql查询到数据表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

在Crystal Report-> Database-> Database Expert-> Command中有一个sql查询.我想在代码中调用它.
怎么做..

请帮助...

Hi All,

there is an sql query inside crystal report->Database->Database expert->Command. I want to call it in the code.
How to do that..

Please help...

推荐答案

string strDBConnection = "Data Source=Localhost;Initial Catalog=Pubs;Persist Security Info=True;User ID=sa;Password=1";
string strCommandText = "SELECT * FROM Employee";

SqlConnection SConnection = new SqlConnection(strDBConnection);
SqlCommand cmd = new SqlCommand(strCommandText, SConnection);
SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(strCommandText, SConnection);
DataSet ds = new DataSet();
sqlDataAdapter.Fill(ds);
ReportDocument rd = new ReportDocument();
rd.Load(Server.MapPath("Report1.rpt"));   
rd.Refresh();
rd.SetDataSource(ds.Tables[0]);
CrystalReportViewer1.ReportSource = rd;
CrystalReportViewer1.DataBind();



谢谢,
Imdadhusen



Thanks,
Imdadhusen


这篇关于水晶报表命令中的sql查询到数据表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 00:21