<pre lang="vb"> Dim cryRpt As New ReportDocument Dim RepPath As String = GetReportAppPath() If RepPath = "NoPath" Then MessageBox.Show("Please set the report location", "Invalid Report Location!", MessageBoxButtons.OK) Me.Close() Else Try cryRpt.Load(RepPath & ReportName & ".rpt") Me.Text = ReportName & System.DateTime.Now.Date Dim _ServerName As String = IP Dim _DatabaseName As String = DB Dim _UserID As String = DBID Dim _Password As String = DBPW Dim Logon As New TableLogOnInfo Dim Tbl As Table For Each Tbl In cryRpt.Database.Tables Logon = Tbl.LogOnInfo Logon.ConnectionInfo.ServerName = _ServerName Logon.ConnectionInfo.DatabaseName = _DatabaseName Logon.ConnectionInfo.Password = _Password Logon.ConnectionInfo.UserID = _UserID Logon.ConnectionInfo.IntegratedSecurity = False Tbl.ApplyLogOnInfo(Logon) Next Dim Subreport As ReportDocument For Each Subreport In cryRpt.Subreports For Each Tbl In Subreport.Database.Tables Logon = Tbl.LogOnInfo Logon.ConnectionInfo.ServerName = _ServerName Logon.ConnectionInfo.UserID = _UserID Logon.ConnectionInfo.Password = _Password Logon.ConnectionInfo.IntegratedSecurity = False Tbl.ApplyLogOnInfo(Logon) Next Next Dim val As String = Para1 Dim paramField As New ParameterField Dim paramDiscreteValue As New ParameterDiscreteValue Dim paramFields As New ParameterFields paramField.Name = "para" paramDiscreteValue.Value = val paramField.CurrentValues.Add(paramDiscreteValue) paramFields.Add(paramField) Select Case ReportName Case "rptSupRFQ_Normal", "rptSupRFQ_Principle", "rptSupRFQ_Direct", "rptQuotation_preview" Dim paramField1 As New ParameterField Dim paramDiscreteValue1 As New ParameterDiscreteValue paramField1.Name = "ItmDes" paramDiscreteValue1.Value = frmNewSearch.chkVenderDesc.Checked paramField1.CurrentValues.Add(paramDiscreteValue1) paramFields.Add(paramField1) Case "rptCusDelv_preview", "rptCusInv_preview" Dim paramField1 As New ParameterField Dim paramDiscreteValue1 As New ParameterDiscreteValue paramField1.Name = "type" paramDiscreteValue1.Value = frmNewSearch.chkOriginal.Checked paramField1.CurrentValues.Add(paramDiscreteValue1) paramFields.Add(paramField1) End Select CrystalReportViewer1.ParameterFieldInfo = paramFields CrystalReportViewer1.ReportSource = cryRpt CrystalReportViewer1.Refresh() Catch ex As Exception el.WriteToErrorLog(ex.Message) Me.Close() End Try End If </pre>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)