c# - Format String for SQL Entry -


the user enters date mm/dd/yyyy in string , needs formatted in c#/asp.net insertion sql server 2008 r2 record. understand should convert datetime , parameterize query, can't find example of this.

what easiest way this?

use datetime.parse , in query add re turned datetime parameter.

var date = datetime.parse(thestring); sqlcommand cmd = new sqlcommand("insert xxx (thedatefield) values(@param1)", con); cmd.parameters.addwithvalue("param1", date);  //execute query , want. 

Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -