c# - Getting records from between Date X and Date Y from my Access database? -


i have table called recharge in access database.

some of fields rechargedate, account, number, etc.

i wanted retrieve records between 2 dates wrote following query:

string query = "select * recharge account='" + combobox1.text + "'  , rechargedate between '"+datetimepicker1.value.date.toshortdatestring()+"' , '"+datetimepicker2.value.date.toshortdatestring()+"'" 

the query runs fine problem i've run in able retrieve dates single month.

if request records span encompasses more single month, not proper result.

any help?

the query executes nice problem can able details between dates in single month, if starting month , ending month differs cant proper result plzz me

maybe you're running string date format issue; try code:

oledbcommand command = new oledbcommand(     "select * recharge " +      "where account=@account , " +      "rechargedate between @rechargedatestart , @rechargedateend"); command.parameters.addwithvalue("@account", combobox1.text); command.parameters.addwithvalue("@rechargedatestart",datetimepicker1.value.date); command.parameters.addwithvalue("@rechargedateend"  ,datetimepicker2.value.date); 

btw, shouldn't try concatenate sql commands, can lead sql injection attacks.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -