Luis Arevalo

I have a problem with the conversion of dates after migrate of VS.NET 2003 to VS.NEt 2005

Test:
Dim oDate As DateTime = DateTime.Parse(oDst.Tables(0).Rows(1).Item("mydate").ToString())

Error:
invalidcastexception .....

In my project of vs.net 2003 worked well that code

I sorry for my inlges ... i speak spanish

Thanks.


Re: .NET Compact Framework VS .NET to VS.NET 2005

Ryan Lamansky

It seems that the date format you were using before is nolonger supported by the normal "Parse" method. If the format is consistent, you can probably get it to work using ParseExact.

If you can determine the exact date format that was supported in 2003 but is not supported in 2005, you may consider filing it as a bug to be fixed in the next version.

-Ryan / Kardax





Re: .NET Compact Framework VS .NET to VS.NET 2005

Ilya Tumanov

Assuming your column holds DateTime already please try this:

Dim oDate As DateTime = CType(oDst.Tables(0).Rows(1).Item("mydate"), System.DateTime)

Also keep in mind if you use Parse() and ToString() like this your code would be very inefficient.

If your column holds a string representing date, it probably fails because of locale specific issues ¨C NETCF V2 uses current locale setting to parse dates unlike NETCF V1. You should be able to fix that by specifying actual format of the date.






Re: .NET Compact Framework VS .NET to VS.NET 2005

Luis Arevalo

The problem is the format of date ....

Test
Dim oDate As DateTime = CType("2006.01.01", System.DateTime)

Error: invalidcastexception

How I can change the format of the date to YYYYMMDD

Thanks.-







Re: .NET Compact Framework VS .NET to VS.NET 2005

Ryan Lamansky

As mentioned above, if the true data type of the field is compatible with DateTime, then definitely use CType for speed and simplicity.

CType cannot be used for parsing strings, though... you must use Parse or ParseExact for that.

For your example, something like

Dim oDate As DateTime = DateTime.ParseExact("2006.01.01", "yyyy.MM.dd", _

System.Globalization.CultureInfo.CurrentCulture)

...should work.

-Ryan / Kardax





Re: .NET Compact Framework VS .NET to VS.NET 2005

Ilya Tumanov

OK, so date is stored as string in the DataSet, not as DateTime. Then you should not cast but should use ParseExact() with format you want:

DateTime.ParseExact("2006.01.01", "yyyy'.'mm'.'dd", Nothing)






Re: .NET Compact Framework VS .NET to VS.NET 2005

Luis Arevalo

Thanks Ryan .... work!!!!!!!






Re: .NET Compact Framework VS .NET to VS.NET 2005

David Amador T.

Other problem ....

I import a group of sentences INSERT from a text file .... test

Insert Into XXXXX Values('UUUUUU','3')
Insert Into XXXXX Values('UUUUUU','3')
Insert Into XXXXX Values('UUUUUU','3')
Insert Into XXXXX Values('UUUUUU','3')
Insert Into XXXXX Values('UUUUUU','3')
Insert Into XXXXX Values('UUUUUU','3')
Insert Into XXXXX Values('UUUUUU','3')
Insert Into XXXXX Values('UUUUUU','3')

The file contains 1000 insert (Aprox); I read lines for lines the file I make the insert

In VS.NET 2003 it works correctly and the process consumes little memory but In VS.NET 2002 the pocket is without space.

How I can specify the factor of growth of the database SQL Mobile

How another thing can be happening

I sorry for my inlges ... i speak spanish

Thanks.








Re: .NET Compact Framework VS .NET to VS.NET 2005

Ilya Tumanov

Please create new thread for each new question. Use correct forum, in this case that would be SQL CE forum.