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

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -