พอมีโค้ด เอาข้อมูลใน Textbox ไปโชว์ใน Crystal Report ไหม!!
ค้นหาข้อมูลแล้วแต่มันขึ้นมาหมดเลยใน Db
ใน module
Code (VB.NET)
Module Module1
Public acscmd As New OleDbCommand
Public DBconn As New OleDbConnection
Public acsda As New OleDbDataAdapter
Public acsds As New DataSet
Public strsql As String
Public strreprotname As String
Sub connect()
DBconn.ConnectionString = "Provider=Microsoft.ace.OLEDB.12.0;Data Source=..\Debug\database.accdb;"
DBconn.Open()
If DBconn.State = ConnectionState.Open Then
MsgBox("Connected")
End If
End Sub
End Module
ใน From load >>> CrystalReportViewer1
Code (VB.NET)
strsql = "select * from tblLease where ID_CTM='" & TextBox1.Text & "'"
acscmd.CommandText = strsql
acscmd.Connection = DBconn
acsda.SelectCommand = acscmd
acsda.Fill(acsds)
strreprotname = "Report1"
Dim strreportpath As String = Application.StartupPath & "\" & strreprotname & ".rpt"
If Not IO.File.Exists(strreportpath) Then
Throw (New Exception("unable to locate report file: " & vbCrLf & strreportpath))
End If
Dim rptdocument As New CrystalDecisions.CrystalReports.Engine.ReportDocument
rptdocument.Load(strreportpath)
rptdocument.SetDataSource(acsds.Tables(0))
CrystalReportViewer1.ReportSource = rptdocument