Dim objConn As OleDbConnection
Dim dtAdapter As OleDbDataAdapter
Dim dt As New DataTable
Dim strConnString As String
strConnString = "provider=microsoft.jet.oledb.4.0;user id=admin;password=;data source = D:\DBproject\project.mdb"
objConn = New OleDbConnection(strConnString)
objConn.Open()
Dim strSQL As String
strSQL = "SELECT book.book_id, "
strSQL = strSQL & "book.book_name, book.Send_no, send.Send_date, book.Sub_no, sub.Sub_date "
strSQL = strSQL & "FROM book LEFT JOIN send ON book.Send_no = send.Send_no "
strSQL = strSQL & "LEFT JOIN sub ON book.Sub_no = sub.Sub_no "
If strKeyWord <> "" Then
strSQL = strSQL & " WHERE send.Send_date Like '%" & strKeyWord & "%'"
strSQL = strSQL & " OR sub.Sub_date Like '%" & strKeyWord & "%'"
strSQL = strSQL & "ORDER BY book.book_id ASC;"
Else
End If
dtAdapter = New OleDbDataAdapter(strSQL, objConn)
dtAdapter.Fill(dt)
dtAdapter = Nothing
objConn.Close()
objConn = Nothing
Me.DataGridView1.DataSource = dt