strPath = Application.StartupPath
strPath = strPath & "/rpt/hurryReturn.rpt"
myReportDoc.Load(strPath)
'程序中向水晶报表传参数
Dim firstParameterValues As New ParameterValues
Dim firstParameterValue As ParameterDiscreteValue
firstParameterValue = New ParameterDiscreteValue(DataGrid1.Item(DataGrid1.CurrentRowIndex, 0))
firstParameterValues.Add(firstParameterValue)
Dim secondParameterValues As New ParameterValues
Dim secondParameterValue As ParameterDiscreteValue
secondParameterValue = New ParameterDiscreteValue
secondParameterValue.Value = "aaa" 'Convert.ToString(DataGrid1.Item(DataGrid1.CurrentRowIndex, 1))
secondParameterValues.Add(secondParameterValue)
myReportDoc.DataDefinition.ParameterFields("@zdbh").ApplyCurrentValues(firstParameterValues)
myReportDoc.DataDefinition.ParameterFields("@jyr").ApplyCurrentValues(secondParameterValues)
'程序中指定报表源
Dim myTableLogonInfo As New TableLogOnInfo
Dim myTable As Table
For Each myTable In myReport.Database.Tables
myTableLogonInfo = myTable.LogOnInfo
With myTableLogonInfo.ConnectionInfo
.ServerName = MainServerName
.DatabaseName = MainDatabase
.UserID = MainUser
.Password = MainPass
End With
myTable.ApplyLogOnInfo(myTableLogonInfo)
Next
CrystalReportViewer1.ReportSource = myReport