建立了数据集dataset,并连接到了数据表C_All_Slaes_Con
主文件代码如下:
protected void Page_Load(object sender, EventArgs e)
{
DataSet ds = new DataSet();
string select = Request.QueryString["sql"];
SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["ConSQL"]);
SqlCommand sqlCmd = new SqlCommand(select, conn);
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = sqlCmd;
da.Fill(ds, "C_All_Slaes_Con"); CrystalReportSource1.ReportDocument.Load(Server.MapPath("RmbxsReport.rpt"));
CrystalReportSource1.ReportDocument.SetDataSource(ds.Tables["C_All_Slaes_Con"]);
CrystalReportSource1.DataBind(); CrystalReportViewer1.ReportSource = CrystalReportSource1;
CrystalReportViewer1.DataBind();
}
报表文件RmbxsReport.rpt通过数据库专家加载了dataset,从数据库字段字拉出几个字段放在了报表中详细资料一栏.
调试时只显示报表框架,没有任何数据...,但数据库中数据是实事存在的,请教了...这问题搞好久了...
主文件代码如下:
protected void Page_Load(object sender, EventArgs e)
{
DataSet ds = new DataSet();
string select = Request.QueryString["sql"];
SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["ConSQL"]);
SqlCommand sqlCmd = new SqlCommand(select, conn);
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = sqlCmd;
da.Fill(ds, "C_All_Slaes_Con"); CrystalReportSource1.ReportDocument.Load(Server.MapPath("RmbxsReport.rpt"));
CrystalReportSource1.ReportDocument.SetDataSource(ds.Tables["C_All_Slaes_Con"]);
CrystalReportSource1.DataBind(); CrystalReportViewer1.ReportSource = CrystalReportSource1;
CrystalReportViewer1.DataBind();
}
报表文件RmbxsReport.rpt通过数据库专家加载了dataset,从数据库字段字拉出几个字段放在了报表中详细资料一栏.
调试时只显示报表框架,没有任何数据...,但数据库中数据是实事存在的,请教了...这问题搞好久了...
ds.Tables["C_All_Slaes_Con"])
然后在看下!你报表内的绑定的字段是否和查出的字段 名相同.
还有一般情况下如果你不想太麻烦的话,你完全可以用空间绑定报表,crystalReport它可以自动让你选择加载的报表,然后把加载的报表crystalReportViewer给它,绑定一下,让它显示就可以了。
string select = Request.QueryString["sql"];
SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["ConSQL"]);
SqlCommand sqlCmd = new SqlCommand(select, conn);
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = sqlCmd;
da.Fill(ds, "C_All_Slaes_Con");
ReportDocument ReportDoc = new ReportDocument();
ReportDoc.Load(Server.MapPath("RmbxsReport.rpt"));
ReportDoc.SetDataSource(ds.Tables["C_All_Slaes_Con"]); CrystalReportViewer1.ReportSource = CrystalReportSource1; 具体的问题没看见整个代码也不好说是那错了啊..你把代码换成这样试试.如果还是不行的话.建议看看水晶报表的基础教程 从新设置一遍.rpt文件
例如原来要传的SQL是:SELECT * FROM C_All_Slaes_Con WHERE (SignTime LIKE '%08%')
到新页面一接受就变成了:SELECT * FROM C_All_Slaes_Con WHERE (SignTime LIKE '08%')
有谁能解释下么?没有不影响结贴,有最好啦.
过一小时结贴.
this.CrystalReportSource1.ReportDocument.SetDataSource(dtSource);
this.CrystalReportSource1.Reflash();<body>
<form id="form1" runat="server">
<div>
<div>
<table style="width: 800px">
<tr>
<td style="width: 800px">
<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="True"
DisplayGroupTree="False" HasPrintButton="True" HasToggleGroupTreeButton="False"
Height="790px" ReportSourceID="CrystalReportSource1" Width="1275px" />
</td>
</tr>
<tr>
<td style="width: 800px; text-align: center">
</td>
</tr>
</table>
</div>
</div>
<CR:CrystalReportSource ID="CrystalReportSource1" runat="server">
<Report FileName="CryChargeInfo.rpt">
</Report>
</CR:CrystalReportSource>
</form>
</body>