i used this codes to show the records but this doesnt works .. but when use the query

("Select * from Schedulings") it works .. it shows the all records. but i want to show the records that satisfy this query..

("Select * from Schedulings where YearLevels = '" & search.TextBox1.Text & "' And Sections = '" & search.TextBox12.Text & "' ", asconn)

Imports System
Imports System.Data
Imports System.Data.OleDb
Imports System.Windows.Forms.Form

Public Class ScheduleStud

Dim con As OleDbConnection
Dim cmd As OleDbCommand
Dim dr As OleDbDataReader
Dim com As OleDbCommand
Dim rid As OleDbDataReader
Dim Con1 As New ADODB.Connection
Dim rs As ADODB.Recordset
Dim ds As DataSet
Dim da As New OleDbDataAdapter
Dim lastrow As Integer
Dim myrow As Data.DataRow

Private Sub ScheduleStud_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    EnlistmentModule.connect()
    showmyrecords()
End Sub
Public Sub showmyrecords()
    Dim lvi As ListViewItem
    Dim dt As New DataTable
    Dim ds As New DataSet
    ds.Tables.Add(dt)
    Dim da As New OleDbDataAdapter("Select * from Schedulings where YearLevels = '" & search.TextBox1.Text & "' And Sections = '" & search.TextBox12.Text & "' ", asconn)
    da.Fill(dt)
    Dim acscmd As New OleDb.OleDbCommand
    acscmd.CommandText = strsql
    acscmd.Connection = asconn


    ListView1.Items.Clear()
    For Each myrow__1 As DataRow In dt.Rows
        lvi = New ListViewItem()
        lvi.Text = myrow__1(5)
        lvi.SubItems.Add(myrow__1(6))
        lvi.SubItems.Add(myrow__1(7))
        lvi.SubItems.Add(myrow__1(8) + "-" + (myrow__1(9)))
        lvi.SubItems.Add(myrow__1(10))
        ListView1.Items.Add(lvi)

    Next



End Sub


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Me.Close()
    asconn.Close()
End Sub
End Class

Are you sure tha the text from the text boxes is being handled correctly?

One thing I do to check entered dates is a small try catch.

Try
    Dim test As Date = CDate(TextBox1.Text)
Catch ex As Exception
    MsgBox("Date incorrect!")
End Try

And for TextBox12, I am assuming it is on another form called "search"?

You might also want to look into placing your code in a try catch block. From what I see, you are leaving yourself open for failures.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.