问题描述
我正在使用Visual Studio 2005开发带有组合框的表单,该组合框将值传递到嵌入式Crystal报表的参数中。我试图弄清楚为什么每次您尝试使用不同的组合框选择来运行报表时,它总是提示我进行数据库登录。
I'm using visual studio 2005 to develop a form with a combobox passing a value into the parameter of an embedded crystal report. I'm trying to figure out why it keeps prompting me for a database login every single time you try to run the report with a different combobox selection.
这是我的代码:
private Sub Form1_load...
Dim ConnName As String
Dim ServerName As String
Dim DBName As String
Dim user As String
Dim pass As String
Dim gDBA As ADODB.Connection
Dim records As ADODB.Recordset
Dim datver As ADODB.Recordset
Dim query As String
'---OPEN THE DATABASE CONNECTIONS
gDBA = New ADODB.Connection ': gDBA.CursorLocation = adUseServer
'Added to prevent time out error
gDBA.CommandTimeout = 1000 : gDBA.ConnectionTimeout = 1000
gDBA.ConnectionString = "Server=svr13;Database=subscribers;User ID=KViews;Password=Solution;Trusted_Connection=True;"
gDBA.Open("Data Source=Kaseya;Initial Catalog=subscribers;User Id=KViews;Password=Solution;", "KViews", "Solution")
records = New ADODB.Recordset
query = "select distinct groupname from _v_k order by groupname desc"
'records.ActiveConnection = gDBA.ConnectionString
records.CursorType = CursorTypeEnum.adOpenForwardOnly
records.LockType = LockTypeEnum.adLockReadOnly
records.Open(query, gDBA)
Do While Not records.EOF
ComboBox1.Items.Add(records.Fields("groupname").Value)
records.MoveNext()
Loop
end Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim selected As String
selected = ComboBox1.Text
Dim cryRpt As New ReportDocument
cryRpt.Load("C:\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\CrystalReport1.rpt")
cryRpt.SetDatabaseLogon("KViews", "Solutions", "svr13", "subscribers")
cryRpt.SetParameterValue("companyname", selected)
CrystalReportViewer1.ReportSource = cryRpt
CrystalReportViewer1.Refresh()
End Sub
我看了之前的帖子
但这不是很有帮助。我找不到CMC禁用提示的位置。
but this wasn't very helpful. I couldn't find where a CMC was to disable the prompt.
有什么想法吗?预先感谢
Any ideas? thanks in advance
推荐答案
将其弄清楚了。以下行不正确
figured it out. the following line was incorrect
cryRpt.SetDatabaseLogon("KViews", "Solutions", "svr13", "subscribers")
它应该是这样的:
cryRpt.SetDatabaseLogon("KViews", "Solutions")
the登录提示不再显示。
the login prompt doesn't show up anymore.
这篇关于Visual Studio嵌入式Crystal报表是否继续提示数据库登录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!