vb.net Crystal Report 总是要求登录数据库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14459966/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Crystal Report always asks for database login
提问by Yohanes AI
I need your help.
我需要你的帮助。
I'm writing code for a shop program and I am using vb.net 2008 with Crystal Report version 10.5.37xxxx
我正在为商店程序编写代码,并且正在使用 vb.net 2008 和 Crystal Report 版本 10.5.37xxxx
The problem is when I'm trying to install my program on the client computer, everything works but not in my Crystal Report. It always asks for the database login and I did not code my program to ask for the database login.
问题是当我尝试在客户端计算机上安装我的程序时,一切正常,但在我的 Crystal Report 中却没有。它总是要求登录数据库,而我没有编写程序来要求登录数据库。
I just wrote it in simple code like this:
我只是用这样的简单代码编写了它:
Public Class Form16
Private Sub Form16_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim view As New CrystalReport4
view.SetParameterValue("p_1", Form5.no_faktur_tb_immanuel)
CrystalReportViewer1.ReportSource = view
End Sub
End Class
Can anyone help me with this?
谁能帮我这个?
采纳答案by ovaltein
You should be able to manually code the login credentials.
您应该能够手动编码登录凭据。
Public Class Form16
Private Sub Form16_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim view As New CrystalReport4
Dim user as string = "Username"
Dim pwd as string = "Password"
view.SetDatabaseLogon(user, pwd)
view.SetParameterValue("p_1", Form5.no_faktur_tb_immanuel)
CrystalReportViewer1.ReportSource = view
End Sub
End Class
回答by Abdusalam Ben Haj
Make Sure your Report DataSource Provider
is set to Microsoft OLE DB provider for SQL Server
and not SQL Server Native Client 10.0
确保你的报告DataSource Provider
被设置为Microsoft OLE DB provider for SQL Server
不SQL Server Native Client 10.0
回答by Shanti Lal Namchuriya
try that open field explorer---> database field --->Right Click -->current Data source --->reports connection----->report ----->property ----> set Property as---
尝试打开字段资源管理器--->数据库字段--->右键单击-->当前数据源--->报告连接----->报告----->属性---->设置属性作为 - -
Data Source: .\Databasename.accdb
数据源:.\Databasename.accdb
and code on viewer form load as
和查看器表单上的代码加载为
Dim cryRpt As New ReportDocument
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 ....
还要更改与数据源相同的报告连接,我认为该代码适合您....
回答by Piar Aly
This will work for you!
这对你有用!
C# Code :
C# 代码:
ConnectionInfo boconnectioninfo = new ConnectionInfo ();
boconnectioninfo.ServerName= "D-2818-w2k";
boconnectioninfo.DatabaseName ="NW";
boconnectioninfo.UserID ="sa";
boconnectioninfo.Password ="sa";
CrystalReportViewer1 .ReportSource = Server.MapPath("CrystalReport1.rpt");
TableLogOnInfos botableInfo= CrystalReportViewer1 .LogOnInfo;
foreach (TableLogOnInfo obj2 in botableInfo)
{
obj2.ConnectionInfo =boconnectioninfo;
}
Vb.net Code :
VB.NET 代码:
Dim boconnectioninfo As New ConnectionInfo
boconnectioninfo.ServerName = "sa"
boconnectioninfo.DatabaseName = "sa"
boconnectioninfo.UserID = "sa"
boconnectioninfo.Password = "sa"
Me.rptViewer.ReportSource = _ReportPath
Me.rptViewer.SelectionFormula = _SelectionFormula
If Not _ParameterFields Is Nothing Then
Me.rptViewer.ParameterFieldInfo = _ParameterFields
End If
Dim a As TableLogOnInfos = Me.rptViewer.LogOnInfo
' Iterate through the list.
For Each aa As TableLogOnInfo In a
aa.ConnectionInfo = boconnectioninfo
Next
Me.Cursor = Cursors.Default
rptViewer.Refresh()