This statement runs correctly when I open a new query on the DB in server explorer.
Now when I run the following code in my code no rows return.
Any thoughts?
Thanks,
Ty
VB.NET:
SELECT ID, [Program Title], [Contact Hours], [Start Date], [Expiration Date], Presenter, [Type of Program], Method FROM Programs WHERE ([Expiration Date] BETWEEN ? AND ?)
Now when I run the following code in my code no rows return.
VB.NET:
Private Sub btnsearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsearch.Click
'Fill the table with the items that expire with in the month and year the user picks in the datetimepicker
Dim dtExpired As Date
Dim dtbegin As Date
Dim dtend As Date
Try
'Get the date the user picked.
dtExpired = DateTimePicker1.Value
'Now get the month and year to be used as the begin date
dtbegin = dtExpired.Month & "/1/" & dtExpired.Year
dtend = dtbegin.AddMonths(1)
cn = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Temp Projects\PSNA Application\PSNA\PSNA\bin\PSNA Application Expiration.accdb;")
'provider to be used when working with access database
cn.Open()
cmd = New OleDbCommand("SELECT ID, [Program Title], [Contact Hours], [Start Date], [Expiration Date], Presenter, [Type of Program], Method FROM Programs WHERE ([Expiration Date] BETWEEN ? AND ?)", cn)
cmd.Parameters.Add(New OleDbParameter("?", dtbegin))
cmd.Parameters.Add(New OleDbParameter("?", dtend))
dr = cmd.ExecuteReader
If dr.HasRows = True Then
'Load the datagrid
DataGridView1.DataSource = dr
End If
Catch ex As Exception
Dim strerror As String
strerror = ex.Message.ToString
System.Diagnostics.Debug.WriteLine(strerror)
End Try
dr.Close()
cn.Close()
End Sub
Any thoughts?
Thanks,
Ty