vb.net - How to get data from access database where date is selected from a date/time picker? -
the database i'm accessing has columns : (id, orderid, sandwich, price, , orderdate). orderdate column format date , time. here's code:
mycon.connectionstring = consl mycon.open() try dim sql string = "select count (*) [hestiasales] [sandwich] = '" & lbldr.text & "' , [orderdate] = #" & orddt.text & "#" dim cmd oledbcommand = new oledbcommand(sql, mycon) dim dr oledbdatareader = cmd.executereader while dr.read qty = dr.item(0) end while cmd.dispose() catch ex exception msgbox(ex.message) end try mycon.close()
i've tried using orddt.value
didn't work, code working fine before added date lines. every time run code says "data type mismatch in criteria expression". ideas? edit: i've date syntax include "#" , no longer previous error, 0 query result, despite having correct time picked either textbox or 'datetimepicker' date "27/03/2017 16:00:
Comments
Post a Comment