c# - Passing a DateTime value as a parameter to an OleDbCommand -


i have problem passing datetime value query dbparameter. seems time part of datetime value gets stripped away.

here sample code in c#:

dbproviderfactory _factory = oledbfactory.instance;  dbcommand cmd = _factory.createcommand(); cmd.commandtext = "insert sometable (somedatefield) values (?)";  dbparameter p = _factory.createparameter(); p.parametername = ""; // not necessary p.value = datetime.now; // assume time != 00:00:00 p.dbtype = dbtype.date; // datetime , datetime2 don't work  cmd.parameters.add(p); 

my problem date parameter not seem reach access it's time part , somedatefield has 00:00:00 time.

i don't want like:

cmd.commandtext = "insert sometable (somedatefield) values (#" + adatetimestring + "#)"; 

make sure data type somedatefield datetime , not date. also, try make

p.dbtype = dbtype.datetime; 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -