Monday, December 10, 2018

Filter database selection from datagridview using Visual Studio


Codes:

Imports System.Data.OleDb
Imports System.Data
Imports System.Data.DataTable
Public Class CashBlotterDatePrint

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Me.Close()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim dt As New DataTable
        Dim str As String = "Select * from CashBlotter where  eDate >= #" & DateTimePicker1.Value.ToShortDateString & "#  and eDate <= #" & DateTimePicker2.Value.ToShortDateString & "# Order  by edate, ID"
        Dim da As New OleDb.OleDbDataAdapter(str, con)
        da.Fill(dt)
        da.Dispose()
        Dim rptDoc As CrystalDecisions.CrystalReports.Engine.ReportDocument
        rptDoc = New CrystalReport78
        rptDoc.SetDataSource(dt)
        Report_Daily_Withdrawal.CrystalReportViewer1.ReportSource = rptDoc
        Dim txt1 As CrystalDecisions.CrystalReports.Engine.TextObject = rptDoc.ReportDefinition.Sections(1).ReportObjects("Text19")
        txt1.Text = DateTimePicker1.Value.ToShortDateString
        Dim txt2 As CrystalDecisions.CrystalReports.Engine.TextObject = rptDoc.ReportDefinition.Sections(1).ReportObjects("Text20")
        txt2.Text = DateTimePicker2.Value.ToShortDateString
        Report_Daily_Withdrawal.Show()
    End Sub
End Class


For information on the coding I used above, leave a comment below.

For more videos, please go to my channel in youtube. You can drop your comments on possible tutorial that we can tackle.

No comments:

Post a Comment

Part 7. Commercial Law. Piercing the viel. Solidary liability

Because a corporation’s existence is only by fiction of law, it can only exercise its rights and powers through its directors, officers, or...