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

How to access named pipes using JavaScript in Firefox add-on? -

multithreading - OPAL (Open Phone Abstraction Library) Transport not terminated when reattaching thread? -

node.js - req param returns an empty array -