代码如下:
Imports CrystalDecisions.Shared
Imports CrystalDecisions.CrystalReports.EnginePublic Class WebForm1
Inherits System.Web.UI.Page
Protected WithEvents CrystalReportViewer1 As CrystalDecisions.Web.CrystalReportViewer#Region " Web 窗体设计器生成的代码 " '该调用是 Web 窗体设计器所必需的。
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() End Sub Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: 此方法调用是 Web 窗体设计器所必需的
'不要使用代码编辑器修改它。
InitializeComponent()
End Sub#End Region Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'在此处放置初始化页的用户代码
Dim LogonInfo As New TableLogOnInfo()
Dim oRpt As New ReportDocument()
oRpt.Load("D:\myweb\creport1\CrystalReport1.rpt") LogonInfo.ConnectionInfo.ServerName = "bmis-server"
LogonInfo.ConnectionInfo.DatabaseName = "balance"
LogonInfo.ConnectionInfo.UserID = "sa"
LogonInfo.ConnectionInfo.Password = "ddddd" oRpt.Database.Tables(0).ApplyLogOnInfo(LogonInfo) '建立.rpt文件与CryStalReportviewer文件之间的连接
CrystalReportViewer1.ReportSource = oRpt
CrystalReportViewer1.DataBind() End SubEnd Class
Imports CrystalDecisions.Shared
Imports CrystalDecisions.CrystalReports.EnginePublic Class WebForm1
Inherits System.Web.UI.Page
Protected WithEvents CrystalReportViewer1 As CrystalDecisions.Web.CrystalReportViewer#Region " Web 窗体设计器生成的代码 " '该调用是 Web 窗体设计器所必需的。
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() End Sub Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: 此方法调用是 Web 窗体设计器所必需的
'不要使用代码编辑器修改它。
InitializeComponent()
End Sub#End Region Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'在此处放置初始化页的用户代码
Dim LogonInfo As New TableLogOnInfo()
Dim oRpt As New ReportDocument()
oRpt.Load("D:\myweb\creport1\CrystalReport1.rpt") LogonInfo.ConnectionInfo.ServerName = "bmis-server"
LogonInfo.ConnectionInfo.DatabaseName = "balance"
LogonInfo.ConnectionInfo.UserID = "sa"
LogonInfo.ConnectionInfo.Password = "ddddd" oRpt.Database.Tables(0).ApplyLogOnInfo(LogonInfo) '建立.rpt文件与CryStalReportviewer文件之间的连接
CrystalReportViewer1.ReportSource = oRpt
CrystalReportViewer1.DataBind() End SubEnd Class
解决方案 »
- 网站图片与代码的分离
- 用cookie 存储 32位的md5密码 在有的时候会丢失,如何解决
- asp.net获取数据库里的数据表并从一个数据库里复制到另外一个数据库???
- 弱弱的问一句,关于CheckBox_CheckedChanged方法的问题
- 急等:关于网络路径与虚拟路径问题,web放在c:\intput\root下,D盘另有一个图片目录,请教怎么得到它的相对路径
- DataSet的生命周期???
- Table与DataTable
- 请教:如何手动设置treeview web控件的高度和宽度?
- c#里怎样调用api?
- 大家好,有下载一个for.net的编辑器,但使不了,不知道为什么!
- 如何动态控制frame框架
- 使用Office Web Components (OWC)来创建统计图
AspNetPager 免费分页控件4.0版发布,欢迎下载使用:http://www.webdiyer.com
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
// 声明所需变量。
TableLogOnInfo logOnInfo = new TableLogOnInfo(); // 这里必须事先申明一个ReportDocument对象 Report,同时加载数据报表
ReportDocument oRpt = new ReportDocument();
string path = Server.MapPath("Report_rpt\\CrystalReport1.rpt"); //oRpt.Load(path); oRpt.Load("D:\\WebApp\\myCrystalReport\\Report_rpt\\CrystalReport1.rpt");
int i = 0; // 对报表中的每个表依次循环。
//for (i=0;i == oRpt.Database.Tables.Count - 1;i++)
//{
// 设置当前表的连接信息。
logOnInfo.ConnectionInfo.ServerName = ConfigurationSettings .AppSettings ["servername"];
logOnInfo.ConnectionInfo.DatabaseName = ConfigurationSettings .AppSettings ["database"];
logOnInfo.ConnectionInfo.UserID = ConfigurationSettings .AppSettings ["userid"];
logOnInfo.ConnectionInfo.Password = ConfigurationSettings .AppSettings ["pass"];
oRpt.Database.Tables [0].ApplyLogOnInfo(logOnInfo);
//}
CrystalReportViewer1.ReportSource = oRpt;
CrystalReportViewer1.DataBind();
// /crystalreportwebformviewer/images/toolbar/upd.gif
}
我就是根据你的程序改写的VB代码,还是无法执行,报告“未将对象引用设置到对象的实例”错误