When I execute the code below against an MDB
database, the data table is empty, however when I run this in a query tool against the database it returns 2 records.
What could be the problem?
Is it an issue with the date format of the parameters (ie. 8/5/13 vs 5/8/13)?
Using oDB As OleDbConnection = GetDbConnection()
Using oCmd As New OleDbCommand("SELECT * " & _
" FROM Table1, Table2" & _
" WHERE (Table1.Date BETWEEN @Date1 AND @Date2) AND (Table1.Id IS NULL) AND (Table2.number = Table1.num) AND (Table1.code1 = Table2.code1) ", oDB)
oCmd.Parameters.AddWithValue("@Date1", Date.Today)
oCmd.Parameters.AddWithValue("@Date2", Date.Today.AddDays(Me.intDaysAhead))
oDB.Open()
dt = New DataTable()
Using da As OleDbDataAdapter = New OleDbDataAdapter(oCmd)
da.Fill(dt)
End Using
End Using
End Using