setting the servername for Crystal Report
I have a form which has a CRViewer, erm..i guess i should put my codes here for easier understanding...
VB Code:
Private Sub frmReport_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim rpt As New Object
Dim paramFields As New CrystalDecisions.Shared.ParameterFields
Dim paramField As New CrystalDecisions.Shared.ParameterField
Dim discreteVal1 As New CrystalDecisions.Shared.ParameterDiscreteValue
Dim discreteVal2 As New CrystalDecisions.Shared.ParameterDiscreteValue
Dim sParamField1 As String
Dim sParamField2 As String
sParamField1 = ""
sParamField2 = ""
rpt = New CliDrill
sParamField1 = "@sCliCode"
discreteVal1.Value = Globals.sSelectedBHCliCode
sParamField2 = "@sBHBranch"
discreteVal2.Value = Globals.sSelectedBHBranch
paramField.ParameterFieldName = sParamField1
paramField.CurrentValues.Add(discreteVal1)
paramFields.Add(paramField)
'Instantiate another object to new param
paramField = New CrystalDecisions.Shared.ParameterField
paramField.ParameterFieldName = sParamField2
paramField.CurrentValues.Add(discreteVal2)
paramFields.Add(paramField)
Me.CrystalReportViewer1.ParameterFieldInfo = paramFields
Dim crConn As New CrystalDecisions.Shared.ConnectionInfo
Dim crDB As CrystalDecisions.CrystalReports.Engine.Database
Dim crTblInfo As New CrystalDecisions.Shared.TableLogOnInfo
Dim crTbls As CrystalDecisions.CrystalReports.Engine.Tables
Dim crTbl As CrystalDecisions.CrystalReports.Engine.Table
crConn.ServerName = "ORISC" ' webser ODBC DNS name
crConn.DatabaseName = "ORISC"
crConn.UserID = "crviewer"
crConn.Password = "crrptonly"
crDB = rpt.Database
crTbls = crDB.Tables
For Each crTbl In crTbls
crTblInfo = crTbl.LogOnInfo
crTblInfo.ConnectionInfo = crConn
crTbl.ApplyLogOnInfo(crTblInfo)
Next
Me.CrystalReportViewer1.ReportSource = rpt
End Sub
Actually the codes worked fine, but i'm a bit confused that why i still need to specify the servername....
VB Code:
crConn.ServerName = "ORISC" ' webser ODBC DNS name
crConn.DatabaseName = "ORISC"
crConn.UserID = "crviewer"
crConn.Password = "crrptonly"
I created the crystal report which, the DB connection is logged to the ODBC, so...it means that i need to specify the servername twice, 1 in the Crystal Report and another time in the codes. I tried to remove that part in my codes but when i try to view my reports, it prompt up the DB connection log on screen..
Any idea/advise/suggestions?
Hope that i've correctly express my questions....
Re: setting the servername for Crystal Report
in the crystal report you can remove the server name, but then the problem is when you open it in the crystal you have to specify the servername to view the data...