473,383 Members | 1,952 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Error on passing Date parameter

I am getting error when debugging a project. The error is as below,


"FormatException was unhandled
String was not recognized as a valid DateTime."

Highlighting the following line

Expand|Select|Wrap|Line Numbers
  1.  
  2. Me.DataTable1TableAdapter.Fill(Me.Sales.DataTable1, DateTime.ParseExact((TextBox1.Text), "MM/dd/yyyy", System.Globalization.CultureInfo.CurrentCulture), DateTime.ParseExact((TextBox2.Text), "MM/dd/yyyy", System.Globalization.CultureInfo.CurrentCulture))
  3.  
  4.  
Please let me know whats the wrong??

Thanks,
Meera.
Jul 24 '10 #1
1 1680
Aimee Bailey
197 Expert 100+
Problem is most likey that you have restrained the format in which date's are allowed to be parsed, using CurrentCulture can be tricky as the current culture is machine and location specifit. I'd reccomend using something more along the lines of:

Expand|Select|Wrap|Line Numbers
  1. Me.DataTable1TableAdapter.Fill(Me.Sales.DataTable1, DateTime.Parse((TextBox1.Text), System.Globalization.CultureInfo.InvariantCulture), DateTime.Parse((TextBox2.Text), System.Globalization.CultureInfo.InvariantCulture))
  2.  
And use a universally formatted date like '2010-07-24 14:00'.

Best of luck!
Jul 24 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Raj | last post by:
hi, How to pass a Two Date parameter to a report at runtime using VB .NET 1. How do we pass multiple values eg. Startdate, EndDate to crystal reports parameter. 2. I have a report to...
2
by: Nautilus | last post by:
Taken from a couple very similar samples on the net, I'm having trouble passing a parameter to a PHP file. Here's all the JS code ... it creates an image object and modifies it's src to make a...
0
by: Dalan | last post by:
I have a select query with a few DSum expressions, but when I add a between and ending date parameter to Date Sold, the results show #Error in two (discount and net sales) of the four gross total...
3
by: IntraRELY | last post by:
I have the following function, Notice how I am passing the dateInterval as a string. What is the correct way to pass "DateInterval.Year" as a variable to a function? TIA, Steve Wofford...
2
by: vaibhav | last post by:
Hi I am writing a wrapper over the XALAN XSLT engine, for transforming XML documents. My problem is that I need to pass date as a parameter ( with format mm/dd/yyyy hh.mm.ss) to the XSLT engine at...
1
by: bhavu10 | last post by:
i got date parameter but it shows only 2007 records and not for other year and would like to know where i have writte code wrong it shows month only from 1/3/2007 to 2/4/2007 not able to figureout...
1
by: Habibur | last post by:
hi, I am using Eclipse plugin,Crystal Report Xi and Oracle 9i as Database and JDBC connection to connect Crystal Report with Database.There are many sql espression in my report file(*.rpt) and date...
1
by: chaitanya02 | last post by:
Hello All, Can anyone help me in passing a Datetime parameter to a webmethod, please? *declaration datetime datetime1; webmethod(out string datetime1); is it the right way of declaring a...
3
beacon
by: beacon | last post by:
Hi everybody, I have a form for every report in this latest database that I use to accept parameters for the underlying query. On the form, I have a command button that launches a calendar module...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.