.net - How to ensure dates are in correct format for OleDbCommand parameters? -


when execute code below against mdb database, data table empty, when run in query tool against database returns 2 records.

what problem?

is issue date format of parameters (ie. 8/5/13 vs 5/8/13)?

using odb oledbconnection = getdbconnection()     using ocmd new oledbcommand("select * " & _             " table1, table2" & _             " (table1.date between @date1 , @date2) , (table1.id null) , (table2.number = table1.num) , (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 oledbdataadapter = new oledbdataadapter(ocmd)             da.fill(dt)         end using     end using end using 

i think right. recommend specify parameter type oledbtype

 ocmd.parameters.add("@date1", oledb.oledbtype.date).value = date.today 

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -