Private Sub BtnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnOK.Click
Dim f2 as New Form2
f2._MemberID=TextID.Text
f2.show()
End sub
ฟอร์มที่สองครับ Code (VB.NET)
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports System.Data
Imports System.Data.SqlClient
Public Class Nisit_rpt
Private _conn As SqlConnection
Privale sub Form2_Load() Handles Me.Load
_conn = New SqlConnection(_conStr)
_conn.Open()
Dim paramValue As New ParameterDiscreteValue
paramValue.Value = TxtID1.Text
Dim paramfid As New ParameterField
paramfid.ParameterFieldName = "MemberID"
paramfid.CurrentValues.Add(paramValue)
Dim paramfields As New ParameterFields
paramfields.Add(paramfid)
CRViewer.ParameterFieldInfo = paramfields
CRViewer.ReportSource = New Nisit()
End sub
End Class
Dim rpt As New ReportDocument
With rpt
.Load("C:\TestReport.rpt", OpenReportMethod.OpenReportByDefault)
.SetDatabaseLogon("username", "password", "servername", "databasename")
End With
' crv = CrystalReportViewer
crv.ReportSource = rpt