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
ASKED: September 2, 2010  4:22 PM
UPDATED: September 3, 2010  8:21 AM

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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • carlosdl
    What is the data type of your "date" column in the sql serer table ?
    65,110 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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

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

Following