This is driving me nuts, been at it now for the last week, anyone any ideas on wher im going wrong?
using a list box pipeLB and a date/time picker pDate, im trying to populate the list box with the rows from the database where the date equals the one selected on the date/time picker. This should happen when i click the button showData.
my database is called PressureReading s and the table inside it is called Pipe1Readings, with columns labelled as key,date and pressure. All it keeps throwing is the exception, but i know the database isnt in use as it tells me, it must be in my code somewhere.
heres my code;
any help would be most appreciated
sorry about the low points - trying to conserve them - waiting for the student loan cheque to come in so i can buy some more.
again - much appreciated in advance.
Ray
using a list box pipeLB and a date/time picker pDate, im trying to populate the list box with the rows from the database where the date equals the one selected on the date/time picker. This should happen when i click the button showData.
my database is called PressureReading s and the table inside it is called Pipe1Readings, with columns labelled as key,date and pressure. All it keeps throwing is the exception, but i know the database isnt in use as it tells me, it must be in my code somewhere.
heres my code;
Code:
Private Sub showData_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles showData.Click
Dim fmtStr As String = "{0,8} {1,15} {2,15} "
Dim i As Integer
Dim tdate As Date
tdate = FormatDateTime(Me.pDate.Value, DateFormat.ShortDate)
'Place contents of Pressures table into a DataTable
Dim dt As New DataTable
Dim connStr As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source = PressureReadings.mdb "
Dim sqlStr As String = "SELECT * FROM Pipe1Readings" ' where date = #" + tdate + "#"
Dim dataAdapter As New OleDb.OleDbDataAdapter(sqlStr, connStr)
Try
dataAdapter.Fill(dt)
Catch
MsgBox("Database Currently in Use - Can't Open")
' End
End Try
dataAdapter.Dispose()
'Fill the list box
pipeLB.Items.Add(String.Format(fmtStr, "DATE", "PRESSURE", "KEY"))
For i = 0 To dt.Rows.Count - 1
pipeLB.Items.Add(String.Format(fmtStr, FormatDateTime(dt.Rows(i)(0), _
DateFormat.ShortDate), dt.Rows(i)(1), dt.Rows(i)(2)))
Next
End Sub
sorry about the low points - trying to conserve them - waiting for the student loan cheque to come in so i can buy some more.
again - much appreciated in advance.
Ray
Comment