加载水晶报告要求数据库登录凭据 [英] loading crystal report asks for database login credentials
问题描述
我创建了一个带有sql身份验证的水晶报告,并提供了用户名sa和passwd。
然后创建了水晶报告。
现在在我的表单中运行时我正在加载报告,它询问数据库登录详细信息。
和我输入后密码,然后数据库中的数据显示在报告中。
如何禁用此功能?
因为每次我必须这样做才能在水晶报告中查看我的数据。
并且在我的表格下按了button_click,我刚刚写了: -
form2.show()/这是查看水晶报告的表格。
任何人都可以帮助我,请如何禁用此选项。
提前致谢
I have created a crystal report with sql authentication and by giving username sa and passwd.
and then have created the crystal report.
now in my form at runtime when i am loading the report, it is asking database login details.
and after i enter the password,then data from database is showing in report.
How to disable this?
Because every time i have to do this to see my data in crystal report.
and in my form under button_click, i have just written:-
form2.show()/ this is the form where crystal report is viewed.
Can anyone help me please how to disable this option.
Thanks in advance
推荐答案
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
将此代码放入报告按钮
put this code into your report button
Try
Dim Report As New YourReportName' CHANGE YourReportName with your report name
' If report name is test.rpt then just use test instead of YourReportName
Dim ConInfo As New CrystalDecisions.Shared.TableLogOnInfo
ConInfo.ConnectionInfo.ServerName = YourServerName ' change with server name
ConInfo.ConnectionInfo.DatabaseName = YourDatabaseName ' change with database name
ConInfo.ConnectionInfo.UserID = "sa"
ConInfo.ConnectionInfo.Password = YourSaPassword ' change with your password
For intCounter As Integer = 0 To Report.Database.Tables.Count - 1
Report.Database.Tables(intCounter).ApplyLogOnInfo(ConInfo)
Next
Dim tmpViewer As New YourReportForm ' change with your Crystal Report Viewer control form
tmpViewer.myCrystalReportViewer.ReportSource = Report
tmpViewer.ShowDialog()
Catch ex As Exception
MsgBox(Err.Description)
End Try
尝试打开字段资源管理器--->数据库字段--->右键单击 - >当前数据源--->报告连接----->报告----->属性---->设置属性为---
数据来源:.\Databasename.accdb
和代码观众形式加载为
Dim cryRpt As New ReportDocument
Dim Report1 As new rptItemWise
Dim strServerName As String
strServerName = Application.StartupPath
rptItemWise.SetDatabaseLogon(admin,,strServerName, dastabasename.accdb,真实的)
cryRpt.Load(Application.StartupPath +\\ \\ rptItemWise.rpt)
也会更改与数据源相同的报表连接我认为该代码适合您....
try that open field explorer---> database field --->Right Click -->current Data source --->reports connection----->report ----->property ----> set Property as---
Data Source: .\Databasename.accdb
and code on viewer form load as
Dim cryRpt As New ReportDocument
Dim Report1 As New rptItemWise
Dim strServerName As String
strServerName = Application.StartupPath
rptItemWise.SetDatabaseLogon("admin", "", strServerName, "dastabasename.accdb", True)
cryRpt.Load(Application.StartupPath + "\rptItemWise.rpt")
also change the report connection same as data source i think that code work for you ....
这篇关于加载水晶报告要求数据库登录凭据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!