Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1022227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:26:02+00:00 2026-05-16T11:26:02+00:00

am using C#, VS 2005 and SQL 2000 I have date conversion problem my

  • 0

am using C#, VS 2005 and SQL 2000

I have date conversion problem my SQL table having field as below

Fields:

datefrom    
dateto

My SQL query in C# is

string sql = "insert into companymast (cname, datefrom, dateto) values(@cname, @datefrom, @dateto)";

SqlCommand cmd = new SqlCommand(sql, con);
cmd.Parameters.Add("@cname",SqlDbType.Varchar(50)).Values = cname.text;
cmd.Parameters.Add("@datefrom",SqlDbType.Datetime).Values = maskedTextBox1.text;
cmd.Parameters.Add("@dateto",SqlDbType.Datetime).Values = maskedTextBox2.text;
cmd.ExecuteNonQuery();

But the above throw Error Like date non conversion string to date

I have to put date in dd/MM/yyyy format code, 103

so how do i do?

Help me out, please.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T11:26:02+00:00Added an answer on May 16, 2026 at 11:26 am

    maskedBox1.text is a string. You’re assigning that to a SqlParameter‘s data member, and it tries to convert whatever it receives to the data type you request.

    A more solid solution would be to convert to DateTime explicitly, and pass the converted value to the SqlParameter. This way, you have more control over the conversion, and you’ll see exactly where and why it goes wrong when it does. Example:

    DateTime fromDate = DateTime.Parse(maskedTextBox1.text);
    cmd.Parameters.Add("@datefrom",SqlDbType.Datetime).Values= fromDate;
    

    For DateTime.Parse, see: http://msdn.microsoft.com/en-us/library/1k1skd40.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 503k
  • Answers 503k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It depends on how you design your classes. You state… May 16, 2026 at 2:50 pm
  • Editorial Team
    Editorial Team added an answer Something like this: screen_coords = (world_coords - camera_world_coords) * camera_zoom… May 16, 2026 at 2:50 pm
  • Editorial Team
    Editorial Team added an answer No, you can use APIs from later versions of the… May 16, 2026 at 2:50 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I am using SQL 2000 and SQL 2005. I want to know which logins
We are using SQL Server 2000 and have to move data across servers to
We have moved a database from SQL 2000 to a new SQL 2005 that
Are there good efficiency savings using Sql Server 2005 over Sql Server 2000? Or
We have an installation of MOSS 2007 that is using MS SQL 2000 as
HI, Using SQL server 2005 I have the following query: SELECT contact_id ,YEAR(date_created) AS
We have a 3rd-party app that wants to call a stored proc using SQL
I apologize in advance for my newbness! Using SQL Server 2005 (9.00.4053.00). It takes
EDIT: I'm still waiting for more answers. Thanks! In SQL 2000 days, I used
(Using SQL Server 2008) I need some help visualizing a solution. Let's say I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.