954,510 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Search the ACCESS 2007 Database using vb.Net 2008

First of all thank to every one for such a dedicated mind to help others......
I have a database in Access 07 name as aaaa and a single table in it table1.The table1 have S.NO(primary key),Customer_Name,Date,Balance.
Now in front end i.e VB.NET 08 i provide a starting date and ending date.The result must show Table1 all fields from particular start date to end date.Another option is by providing a particular date must show details of that date only.

1.Which connection method i can prefer to connect database ?
2.which view for result is suitable to this ?
3.And i prefer two text boxes for provide from and to date.single test box for sing date search.A button named as Search.Is it correct ?
4.what is the code to search in the database and load in result ?

please help me because around two years i have waiting for this.....Or please please it may be a silly and easy program to you worked in some minutes...send it to my id [email]gurupts13@gmail.com[/email] ....again Thank you for every one.

gurupts
Newbie Poster
15 posts since Jul 2010
Reputation Points: 10
Solved Threads: 0
 

1. The connection string is the easy one.
Provider=Microsoft.ACE.OLEDB.12.0;Data ource=<path to file>\database.accdb;Persist Security Info=False; .

2. It depends. If you know that more than one record will be returned, then storing them in a DataTable would be good.
From there you can browse each record by the simple use of an index value.

3. Then that's what you should go with.

4. This is an example for locating and storing the results in a DataTable.

Imports System.Data.OleDb

Private table1 As DataTable

Private Sub SearchDatabase()
   Dim connectionString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data ource=<path to file>\database.accdb;Persist Security Info=False;"
   Dim connection As New OleDbConnection(connectionString)
   Dim adapter As New OleDbDataAdapter()
   Dim command As OleDbCommand()

   Try
      connection.Open()
      If txtBoxSingleDate.Text.Equals("") Then
         command = New OleDbCommand("SELECT * FROM table1 WHERE [Date] BETWEEN '" & txtBoxDate1.Text & "' AND '" & txtBoxDate2.Text & "'", connection)
      Else
         command = New OleDbCommand("SELECT * FROM table1 WHERE [Date] = '" & txtBoxSingleDate.Text & "'", connection)
      End If

      table1 = New DataTable("table1")
      adapter.Fill(table1)

      connection.Close()
   Catch ex As Exception
   End try
End Sub
Oxiegen
Master Poster
715 posts since Jun 2006
Reputation Points: 87
Solved Threads: 141
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: