Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27472

VS 2010 Multi-Searching an Access Database.

$
0
0
Hi guys,

I've recently started learning VB 2010 and I am currently working on a project that is a Book shop database. The database is an Access database

I need to be able to search the database by Author, Book Title, ISBN etc...

So far I can get it to search one parameter at a time, but i'd like the program to be able to search using a number of parameters, while ignoring the text boxes that I leave blank. I'm an amateur at this :blush:

Here's a sample of the code i've used that allows me to search using just one parameter(Text box).

Code:

        Dim query = From book In Book_ShopDataSet.Books
                    Where book.BookTitle = txtTitle.Text
                    Select book.ISBN, book.BookTitle, book.Author, book.Genre, book.Publisher, book.RRP, book.FirstPublished
        If query.Count = 1 Then
            frmResults.Show()
            frmResults.dgvOutput.DataSource = query.ToList
            frmResults.dgvOutput.CurrentCell = Nothing
        Else
            MessageBox.Show("Book Not Found in Database", "Not Found")
        End If

The results of the search are shown in a second form called frmResults in a Data Grid View box.

Some help and advice would be much appreciated. :)

Viewing all articles
Browse latest Browse all 27472

Trending Articles