I'm using Access as a backing data store (I know why not use MySQL right?). Anyway, getting over that, I want to use SQL to search for a booking date on my database. I can get it to look up todays date but I'd like some way of typing in a date and then finding results based on this. My code so far is this:
Public Class Bookings
Dim con As New OleDb.OleDbConnection
Dim dbProvider As String
Dim dbSource As String
Dim ds As New DataSet
Dim da As OleDb.OleDbDataAdapter
Dim sql As String
Private Sub Bookings_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
dbProvider = "PROVIDER=Microsoft.Jet.OleDB.4.0;"
dbSource = "Data Source = C:\Users\wm\Desktop\MAdams\Karting2000DB.mdb"
con.ConnectionString = dbProvider & dbSource
con.Open()
sql = "SELECT * FROM tblBookings WHERE BookingDate = txtDate.Text"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "AddressBook")
MsgBox("Database is now open")
con.Close()
MsgBox("Database is now closed")
txtBookingNumber.Text = ds.Tables("AddressBook").Rows(0).Item("ID")
txtCustID.Text = ds.Tables("AddressBook").Rows(0).Item("CustomerID")
End Sub
End Class
I'm pretty new to this so simpler the better!
Many thanks
Path.CombineandEnvironment.GetFolderPath