VS2005 水晶報表 您请求的报表需要更多信息.
各位,小弟刚刚接触水晶报表.现在做一个列子.遇到一点问题
希望各位能帮帮小弟,
页面后台:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Web;
using CrystalDecisions.Shared;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DataSet ds = new DataSet();
SqlDataAdapter sda = new SqlDataAdapter();
string conStr = "server=.;database=Test;uid=sa;pwd=sa.";
SqlConnection conn = new SqlConnection(conStr);
//conn.Open();
//SqlCommand comm = conn.CreateCommand();
sda = new SqlDataAdapter("select ID,AdminPage from Scan_AdminLogin", conn);
sda.Fill(ds, "Scan_AdminLogin");
ReportDocument rd = new ReportDocument();
string MyPath = Server.MapPath(@"App_Code/CrystalReport.rpt");
rd.Load(MyPath);
rd.SetDataSource(ds.Tables["Scan_AdminLogin"]);
CrystalReportViewer1.ReportSource = rd;
//CrystalReportViewer1.DataBind();
//conn.Close();
}
}
页面前台:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="CrystalDecisions.Web, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"
Namespace="CrystalDecisions.Web" TagPrefix="CR" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<link href="/aspnet_client/System_Web/2_0_50727/CrystalReportWebFormViewer3/css/default.css"
rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<div>
<cr:crystalreportviewer id="CrystalReportViewer1" runat="server" autodatabind="true"></cr:crystalreportviewer>
</div>
</form>
</body>
</html>
我是用DATASET数据集做的.
CrystalReport.rpt 中我用数据专家连接 项目数据 ADO.NET数据集 选择了我刚刚建的那个DataSet1数据集,我在这个数据集中建了四张表.
分别是:
表:Scan_AdminLogin 列:ID,AdminPage
表:UserInfo 列:ID,Name,Address,Phone
表:TypeName 列:ID,TypeName
表:GoodsInfo 列:ID,UID,Number,Name,Title,TID
在CrystalReport.rpt 中我只用了Scan_AdminLogin表的ID,它就说
您请求的报表需要更多信息.
--------------------------------------------
DataSet1
服务器名:
数据库名:
用户名:
密码:
使用集成安全性
------解决方案--------------------你DataSet1的结构和DataSet一致吗
参考
http://topic.csdn.net/u/20090626/18/0e7d0af0-2555-479d-9cb5-84175787f2cd.html?83121
------解决方案--------------------改一个连接字符串试试:
Data Source=HH-LIN\SQL2005;Initial Catalog=test;User ID=sa;Password=sa
HH-LIN\SQL2005为本机的数据库实例,Initial Catalog为数据库名,后面两个为用户ID和密码
------解决方案--------------------