|
-
May 23rd, 2007, 12:25 PM
#1
Thread Starter
Lively Member
Error 166 System.DateTime.TryParse(string, out System.DateTime)
Hi,
I get this error when i write the following line of code:
if (DateTime.TryParse(drow[dt.DateCol.Caption].ToString(), resub))
this line executes well on another machine in our network which has the same version of framework as mine. but shows the following error in my machine.
Error 166 The best overloaded method match for 'System.DateTime.TryParse(string, out System.DateTime)' has some invalid arguments
Error 167 Argument '2' must be passed with the 'out' keyword
please help me how to get rid of this
-
May 23rd, 2007, 01:10 PM
#2
Re: Error 166 System.DateTime.TryParse(string, out System.DateTime)
You have to put 'out' before the output variable.
C# Code:
if (DateTime.TryParse(drow[dt.DateCol.Caption].ToString(), out resub))
-
May 23rd, 2007, 01:23 PM
#3
Thread Starter
Lively Member
Re: Error 166 System.DateTime.TryParse(string, out System.DateTime)
you are right.
but the same syntax (without Out keyword) works fine on another machine and shows error in mine.
-
May 23rd, 2007, 07:28 PM
#4
Re: Error 166 System.DateTime.TryParse(string, out System.DateTime)
My question is: why are you getting a date value as a string from a database at all? If you want to store date/time values in a database you should be storing them as binary date/time values in a date/time column. That way the database will return DateTime values to you and there's no need to parse at all.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|