SqlConnection cn = new SqlConnection(st_SqlString);
string sql = "select * from ST_CourseInfo";
SqlDataAdapter da = new SqlDataAdapter(sql, cn);
DataSet ds = new DataSet();
da.Fill(ds);
CrystalReport rpt = CrystalReportViewer1();
rpt.SetDataSorce(ds.Tables[0]);
CrystalReportViewer1.ReportSource = rpt;
ViewBrowser时总提示:The type or namespace name 'CrystalReport' could not be found (are you missing a using directive or an assembly reference?)
应该怎样解决呀?谢谢!
19 个解决方案
#1
需要引用一下水晶报表. 在引用的地主点右键,引用,然后就可以看到了.
#2
在报表所在项目下做了引用,在引用窗口下的.net标签下有关crystalreport的组件都做了引用,可问题依旧,请高手指点...
#3
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using CrystalDecisions.Shared;
#4
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 System.Data.Sql;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
public partial class ST_Admin_ST_Report : System.Web.UI.Page
{
string st_SqlString = System.Configuration.ConfigurationSettings.AppSettings["ConnString"];
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection cn = new SqlConnection(st_SqlString);
string sql = "select * from ST_CourseInfo";
SqlDataAdapter da = new SqlDataAdapter(sql, cn);
DataSet ds = new DataSet();
da.Fill(ds);
CrystalReport rpt = CrystalReport();
rpt.SetDataSorce(ds.Tables[0]);
CrystalReportViewer1.ReportSource = rpt;
}
}
怎么问题还是依旧呢?
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 System.Data.Sql;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
public partial class ST_Admin_ST_Report : System.Web.UI.Page
{
string st_SqlString = System.Configuration.ConfigurationSettings.AppSettings["ConnString"];
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection cn = new SqlConnection(st_SqlString);
string sql = "select * from ST_CourseInfo";
SqlDataAdapter da = new SqlDataAdapter(sql, cn);
DataSet ds = new DataSet();
da.Fill(ds);
CrystalReport rpt = CrystalReport();
rpt.SetDataSorce(ds.Tables[0]);
CrystalReportViewer1.ReportSource = rpt;
}
}
怎么问题还是依旧呢?
#5
你的寫法不對,
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
MyreportDocument = new ReportDocument();
MyreportDocument.Load(@"C:\Documents and Settings\micao.tao\My Documents\Visual Studio 2005\WebSites\WEBTEST\HXTest\CrystalReport.rpt");
DataSet dataSet = GetdataSet();
MyreportDocument.SetDataSource(dataSet);
this.CrystalReportViewer1.ReportSource = MyreportDocument;
// GetdataSet();返回一個dataset
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
MyreportDocument = new ReportDocument();
MyreportDocument.Load(@"C:\Documents and Settings\micao.tao\My Documents\Visual Studio 2005\WebSites\WEBTEST\HXTest\CrystalReport.rpt");
DataSet dataSet = GetdataSet();
MyreportDocument.SetDataSource(dataSet);
this.CrystalReportViewer1.ReportSource = MyreportDocument;
// GetdataSet();返回一個dataset
#6
Micao_tong(天平),你的这个思路是要先建立.rpt文件吧,是空表文件吗?数据来自哪里?
我看了一篇文章说象我上面这样也可以呀,但是就是CrystalReport类引用不到,如果用我上面的思路的话有解决的办法吗?
我看了一篇文章说象我上面这样也可以呀,但是就是CrystalReport类引用不到,如果用我上面的思路的话有解决的办法吗?
#7
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using CrystalDecisions.Shared;
#8
这两句命名空间引用语句我有加呀,可还是提示:
The type or namespace name 'CrystalReport' could not be found (are you missing a using directive or an assembly reference?),怎么办呢?
The type or namespace name 'CrystalReport' could not be found (are you missing a using directive or an assembly reference?),怎么办呢?
#9
up
#10
up
#11
up
#12
用下述代码:
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
public partial class ST_Admin_ST_Report : System.Web.UI.Page
{
string st_SqlString = System.Configuration.ConfigurationSettings.AppSettings["ConnString"];
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection cn = new SqlConnection(st_SqlString);
string sql = "select * from ST_CourseInfo";
SqlDataAdapter da = new SqlDataAdapter(sql, cn);
DataSet ds = new DataSet();
da.Fill(ds);
CrystalDecisions.CrystalReports.Engine.ReportClass rpt = new CrystalDecisions.CrystalReports.Engine.ReportClass();
rpt.SetDataSource(ds.Tables[0]);
CrystalReportViewer1.ReportSource = rpt;
}
}
报错: “rpt.SetDataSource(ds.Tables[0]);”
String reference not set to an instance of a String.
请高手给分析下问题在哪里?
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
public partial class ST_Admin_ST_Report : System.Web.UI.Page
{
string st_SqlString = System.Configuration.ConfigurationSettings.AppSettings["ConnString"];
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection cn = new SqlConnection(st_SqlString);
string sql = "select * from ST_CourseInfo";
SqlDataAdapter da = new SqlDataAdapter(sql, cn);
DataSet ds = new DataSet();
da.Fill(ds);
CrystalDecisions.CrystalReports.Engine.ReportClass rpt = new CrystalDecisions.CrystalReports.Engine.ReportClass();
rpt.SetDataSource(ds.Tables[0]);
CrystalReportViewer1.ReportSource = rpt;
}
}
报错: “rpt.SetDataSource(ds.Tables[0]);”
String reference not set to an instance of a String.
请高手给分析下问题在哪里?
#13
没有高手给指导一下吗?
#14
顶下去..我也想知...难道不可以打印动态dataset吗?
#15
试了一下,至少编译没问题的,不过一般都是直接传dataset的。
另外不得不说,你这代码即使没问题,最后运行也是看不到东西的。因为你建了一个空的rpt,没有任何内容。一般是在solution explorer那里右击添加new item,添加一个新的水晶报表,然后跟着它的创建wizard创建报表,要修改的话也双击那个rpt文件,然后在那个打开的编辑器里添加一些字段,排版什么的,这样你的报表才会有内容显示在crystalreporviewer里。
另外不得不说,你这代码即使没问题,最后运行也是看不到东西的。因为你建了一个空的rpt,没有任何内容。一般是在solution explorer那里右击添加new item,添加一个新的水晶报表,然后跟着它的创建wizard创建报表,要修改的话也双击那个rpt文件,然后在那个打开的编辑器里添加一些字段,排版什么的,这样你的报表才会有内容显示在crystalreporviewer里。
#16
真晕 说了半天什么都没说出来 跟没说一个样嘛
#17
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using CrystalDecisions.Shared;
#18
using CrystalDecisions.Shared;
using CrystalDecisions.CrystalReports.Engine;
有装CrystalReport吗??
using CrystalDecisions.CrystalReports.Engine;
有装CrystalReport吗??
#19
#20
#1
需要引用一下水晶报表. 在引用的地主点右键,引用,然后就可以看到了.
#2
在报表所在项目下做了引用,在引用窗口下的.net标签下有关crystalreport的组件都做了引用,可问题依旧,请高手指点...
#3
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using CrystalDecisions.Shared;
#4
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 System.Data.Sql;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
public partial class ST_Admin_ST_Report : System.Web.UI.Page
{
string st_SqlString = System.Configuration.ConfigurationSettings.AppSettings["ConnString"];
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection cn = new SqlConnection(st_SqlString);
string sql = "select * from ST_CourseInfo";
SqlDataAdapter da = new SqlDataAdapter(sql, cn);
DataSet ds = new DataSet();
da.Fill(ds);
CrystalReport rpt = CrystalReport();
rpt.SetDataSorce(ds.Tables[0]);
CrystalReportViewer1.ReportSource = rpt;
}
}
怎么问题还是依旧呢?
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 System.Data.Sql;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
public partial class ST_Admin_ST_Report : System.Web.UI.Page
{
string st_SqlString = System.Configuration.ConfigurationSettings.AppSettings["ConnString"];
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection cn = new SqlConnection(st_SqlString);
string sql = "select * from ST_CourseInfo";
SqlDataAdapter da = new SqlDataAdapter(sql, cn);
DataSet ds = new DataSet();
da.Fill(ds);
CrystalReport rpt = CrystalReport();
rpt.SetDataSorce(ds.Tables[0]);
CrystalReportViewer1.ReportSource = rpt;
}
}
怎么问题还是依旧呢?
#5
你的寫法不對,
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
MyreportDocument = new ReportDocument();
MyreportDocument.Load(@"C:\Documents and Settings\micao.tao\My Documents\Visual Studio 2005\WebSites\WEBTEST\HXTest\CrystalReport.rpt");
DataSet dataSet = GetdataSet();
MyreportDocument.SetDataSource(dataSet);
this.CrystalReportViewer1.ReportSource = MyreportDocument;
// GetdataSet();返回一個dataset
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
MyreportDocument = new ReportDocument();
MyreportDocument.Load(@"C:\Documents and Settings\micao.tao\My Documents\Visual Studio 2005\WebSites\WEBTEST\HXTest\CrystalReport.rpt");
DataSet dataSet = GetdataSet();
MyreportDocument.SetDataSource(dataSet);
this.CrystalReportViewer1.ReportSource = MyreportDocument;
// GetdataSet();返回一個dataset
#6
Micao_tong(天平),你的这个思路是要先建立.rpt文件吧,是空表文件吗?数据来自哪里?
我看了一篇文章说象我上面这样也可以呀,但是就是CrystalReport类引用不到,如果用我上面的思路的话有解决的办法吗?
我看了一篇文章说象我上面这样也可以呀,但是就是CrystalReport类引用不到,如果用我上面的思路的话有解决的办法吗?
#7
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using CrystalDecisions.Shared;
#8
这两句命名空间引用语句我有加呀,可还是提示:
The type or namespace name 'CrystalReport' could not be found (are you missing a using directive or an assembly reference?),怎么办呢?
The type or namespace name 'CrystalReport' could not be found (are you missing a using directive or an assembly reference?),怎么办呢?
#9
up
#10
up
#11
up
#12
用下述代码:
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
public partial class ST_Admin_ST_Report : System.Web.UI.Page
{
string st_SqlString = System.Configuration.ConfigurationSettings.AppSettings["ConnString"];
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection cn = new SqlConnection(st_SqlString);
string sql = "select * from ST_CourseInfo";
SqlDataAdapter da = new SqlDataAdapter(sql, cn);
DataSet ds = new DataSet();
da.Fill(ds);
CrystalDecisions.CrystalReports.Engine.ReportClass rpt = new CrystalDecisions.CrystalReports.Engine.ReportClass();
rpt.SetDataSource(ds.Tables[0]);
CrystalReportViewer1.ReportSource = rpt;
}
}
报错: “rpt.SetDataSource(ds.Tables[0]);”
String reference not set to an instance of a String.
请高手给分析下问题在哪里?
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
public partial class ST_Admin_ST_Report : System.Web.UI.Page
{
string st_SqlString = System.Configuration.ConfigurationSettings.AppSettings["ConnString"];
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection cn = new SqlConnection(st_SqlString);
string sql = "select * from ST_CourseInfo";
SqlDataAdapter da = new SqlDataAdapter(sql, cn);
DataSet ds = new DataSet();
da.Fill(ds);
CrystalDecisions.CrystalReports.Engine.ReportClass rpt = new CrystalDecisions.CrystalReports.Engine.ReportClass();
rpt.SetDataSource(ds.Tables[0]);
CrystalReportViewer1.ReportSource = rpt;
}
}
报错: “rpt.SetDataSource(ds.Tables[0]);”
String reference not set to an instance of a String.
请高手给分析下问题在哪里?
#13
没有高手给指导一下吗?
#14
顶下去..我也想知...难道不可以打印动态dataset吗?
#15
试了一下,至少编译没问题的,不过一般都是直接传dataset的。
另外不得不说,你这代码即使没问题,最后运行也是看不到东西的。因为你建了一个空的rpt,没有任何内容。一般是在solution explorer那里右击添加new item,添加一个新的水晶报表,然后跟着它的创建wizard创建报表,要修改的话也双击那个rpt文件,然后在那个打开的编辑器里添加一些字段,排版什么的,这样你的报表才会有内容显示在crystalreporviewer里。
另外不得不说,你这代码即使没问题,最后运行也是看不到东西的。因为你建了一个空的rpt,没有任何内容。一般是在solution explorer那里右击添加new item,添加一个新的水晶报表,然后跟着它的创建wizard创建报表,要修改的话也双击那个rpt文件,然后在那个打开的编辑器里添加一些字段,排版什么的,这样你的报表才会有内容显示在crystalreporviewer里。
#16
真晕 说了半天什么都没说出来 跟没说一个样嘛
#17
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using CrystalDecisions.Shared;
#18
using CrystalDecisions.Shared;
using CrystalDecisions.CrystalReports.Engine;
有装CrystalReport吗??
using CrystalDecisions.CrystalReports.Engine;
有装CrystalReport吗??