本地处理期间发生错误 [英] An error occured during local processing
本文介绍了本地处理期间发生错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想帮助解决这个问题。在客户端PC上安装项目后,Microsoftreportviewer显示错误。从visual studio进行测试时它工作正常但是在使用安装项目在客户端PC上安装后它总是显示错误。
Bello是我的代码
Please I want a help this problem. After I install my project on a client pc, the Microsoftreportviewer show an error. It works fine when testing from visual studio but after installing it on a client pc using the setup project it always show error.
Bello is my code
Imports MySql.Data.MySqlClient
Imports Microsoft.Reporting.WinForms
Public Class CarReportForm
' Connection string definition
Private connString As String = _
"Server=myserver;Port=3306;Database=hotelmanagementsystemn;Uid=root;Pwd=ben10@@;"
Private Sub CarReportForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
With Me.ReportViewer1.LocalReport
' Report path
.ReportPath = Application.StartupPath & "\..\..\CarReport.rdlc"
.DataSources.Clear()
End With
' ----------------------------------------------------
' Datasource for the main report
' ----------------------------------------------------
Dim SQL As String = "SELECT Car_ID, Car_No, Car_Type, Full_Name, Room_No, Floor_No, Rent_Charge, Num_of_Cars, Total_Price, Date_Value FROM CarRent_T"
Using da As New MySqlDataAdapter(SQL, connString)
Using ds As New DataSet
da.Fill(ds, "viewcar")
' You must use the same name as defined in the report Data Source Definition
Dim rptDataSource As New ReportDataSource("dsCar_viewcar", ds.Tables("viewcar"))
Me.ReportViewer1.LocalReport.DataSources.Add(rptDataSource)
End Using
End Using
' Refresh the report
ReportViewer1.RefreshReport()
' Add the handler for the subreport
AddHandler ReportViewer1.LocalReport.SubreportProcessing, AddressOf SubreportProcessingEvent
Catch ex As Exception
MessageBox.Show(ex.Message, My.Application.Info.Title, MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Sub SubreportProcessingEvent(ByVal sender As Object, ByVal e As SubreportProcessingEventArgs)
Try
Dim SQL As String = "SELECT Hotel_Name, Hotel_Address, Hotel_Phone, Email_Address FROM HotelProfile"
Using da As New MySqlDataAdapter(SQL, connString)
Using ds As New DataSet
da.Fill(ds, "viewhotelpro")
Dim rptDataSource As New ReportDataSource("dsCar_viewhotelpro", ds.Tables("viewhotelpro"))
e.DataSources.Add(rptDataSource)
End Using
End Using
Catch ex As Exception
MessageBox.Show(ex.Message, My.Application.Info.Title, MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
End Class
推荐答案
请参阅我对该问题的评论。到目前为止,它还不完整。您没有解释重现的步骤,您获得的异常等等。问题可能在您显示的代码中,也可能不在。您需要使用调试器或记录并研究日志。
如果您的应用程序确实在本地工作而在部署后没有,我只能看到两个可疑的部分区别:连接字符串和路径\..\..\CarReport.rdlc。请检查它们是否在其他托管环境中有效。您确定可以从托管网站访问相同或相同的数据库吗?你确定RDLC文件在那里吗? Web应用程序只能访问为您的站点配置的根目录下的路径。
但同样,问题可能出在代码的其他部分。你只是没有采取适当的步骤来调查这个问题。
-SA
Please see my comment to the question. So far, it is incomplete. You did not explain steps to reproduce, what exception do you get, etc. The problem may or may not be in the code you show. You need to use the debugger or logging and study the logs.
If your application really worked locally and did not after deployment, I can see only two questionable piece which could make difference: connection string and the path "\..\..\CarReport.rdlc". Please check up if they are valid in a different hosting environment. Are you sure the same or identical database is accessible from the hosted site? Are you sure that RDLC file is there? A Web application can only access paths under the root directory configured for your site.
But again, the problem could be in some other part of code. You just did not do proper steps to investigate the problem.
—SA
这篇关于本地处理期间发生错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文