I have a button to show another form and send parameters to a crystal report, but after I click that button it always show database login, and I have to input username and password. When I tick off "use integrated security instead" it failed. My question is how to connect to database without showing the login?
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Public Class param_list_agree
Private Sub Cmdpreview_Click(sender As Object, e As EventArgs) Handles Cmdpreview.Click
Call opendb()
Dim cryrpt As New ReportDocument
cryrpt.Load("D:\Report\List_Agreement.rpt")
Dim crparamdfs As ParameterFieldDefinitions
Dim crparamdf As ParameterFieldDefinition
Dim crparamvl As New ParameterValues
Dim crparamdisvl As New ParameterDiscreteValue
Dim konek As New ConnectionInfo
crparamdisvl.Value = DTP1.Text
crparamdfs = cryrpt.DataDefinition.ParameterFields
crparamdf = crparamdfs.Item("@date_to")
crparamvl = crparamdf.CurrentValues
crparamvl.Clear()
crparamvl.Add(crparamdisvl)
crparamdf.ApplyCurrentValues(crparamvl)
rpt_listagree.CrystalReportViewer1.ReportSource = cryrpt
rpt_listagree.CrystalReportViewer1.Refresh()
rpt_listagree.Show()
'CrystalReportViewer1.ReportSource = cryrpt
'CrystalReportViewer1.Refresh()
With konek
.ServerName = "ServerName"
.DatabaseName = "DatabaseName"
.UserID = "UserID"
.Password = "Password"
.IntegratedSecurity = False
End With
Me.Close()
End Sub
Private Sub param_list_agree_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Call opendb()
End Sub
End Class
For starters, always set your login info before you load/set parameters. If parameters are dynamic in any way, they will try to access the database, and no login info has been set.
Anytime you get the pop-up dialogue to login, it means Crystal tried to access the database in report before the connection settings were set (or the connection info is incorrect).
*** EDIT