水晶报表命令中的sql查询到数据表中 [英] sql query inside command of crystal report into data table

查看:66
本文介绍了水晶报表命令中的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...

推荐答案


使用以下

Hi,
Use following

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查询到数据表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆