Parameter Date Conversion in SQL 2000

260 pts.
Tags:
C#
SQL
SQL 2000
SQL commands
SQL Parameters
SQL Server
String manipulation
Visual Studio 2005
my code is :
string sql="insert into dummy(date)values(@date)";
sqlcommand cmd=new sqlcommand(sql,con);
cmd.parameters.add("@date",sqldbtype.datetime).values=maskedtextbox1.text
text;
cmd.executenonquery();
the problem is it's throw and error like  conversion of varchar to date;
Note :- my demand to put date in DD/MM/YYYY format. 


Software/Hardware used:
C#,VS-2005,SQL-2000

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • carlosdl
    What is the data type of your "date" column in the sql serer table ?
    78,855 pointsBadges:
    report
  • Maheshwag
    the datatype in sql server is datetime but in my c# application i have to put the date in maskedtextbox1.tex = 31/03/2010 like "DD/MM/YYYY format and maskedtextbox returns strings that's why the problems occures in straightway like below.
    "insert into dummy(date)values(convert(datetime,' " + maskedtextbox.text.tostring()+" ',103)";
    
    it's works but in parameteriz it not accept. so how to do with same please tell me.
    260 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: