Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / November 2006

Tip: Looking for answers? Try searching our database.

Wrapping a date field so precision is not lost?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
SenseiHitokiri - 14 Nov 2006 21:01 GMT
I learned today that an insert statement I am generating out of a
DataSet which gets populated straight from SqlDataReaders is not giving
me the same precision that it is stored in the database with.

Table 1 (Origin table)
Nov  8 2006  5:19:10:617PM

is being stored as

Table 2 (Destination Table)
Nov  8 2006  5:19:10:000PM

because the insert looks like

SET [CREATE_DATE]='11/8/2006 5:19:10 PM'

When I am reading from Table 1 into the Dataset and displaying it in a
DataGridView it shows up as 11/8/2006 5:19 PM.  So then when I try to
write an insert string for a SqlCommand object I just try to append the
field from the DataSet.  The insert string is generated like this
[CREATE_DATE]='11/8/2006 5:19:10 PM'.  Is there a way to get my dataset
to handle this precision on it's own?  I don't want to write methods
that will parse the string for the word date and I don't want to create
a library of table columns because that may run into it's own problems.
So basically I'm left with two options in my eyes: Figure out how to
get the dataset to realize the columns precision or Write a method to
determine the column's type and then apply the proper formatting to the
string.
Rad - 14 Nov 2006 21:26 GMT
>I learned today that an insert statement I am generating out of a
>DataSet which gets populated straight from SqlDataReaders is not giving
[quoted text clipped - 24 lines]
>determine the column's type and then apply the proper formatting to the
>string.

There's a difference between the storage of datetime values in the
.NET framework and SQL Server. Read these articles for some details of
the difference and some possible workarous:

http://www.velocityreviews.com/forums/t111968-datetime-problem.html

http://www.eggheadcafe.com/articles/20021111.asp

http://blogs.wdevs.com/angelos/archive/2005/06/02/3660.aspx
SenseiHitokiri - 15 Nov 2006 17:24 GMT
> >I learned today that an insert statement I am generating out of a
> >DataSet which gets populated straight from SqlDataReaders is not giving
[quoted text clipped - 34 lines]
>
> http://blogs.wdevs.com/angelos/archive/2005/06/02/3660.aspx

Thanks that really helped me to understand the difference between the
two types but it leaves me with this question which is half-aimed at
the world and half-aimed at Microsoft.  Why would a dataset fill itself
with a datatype that isn't the same as the table's especially when I'm
using Microsoft SQL Server.  I mean it's looking like my options are
either to create some new calculated field in the table ( which I don't
actually have permission to do since it would be modifying some clossal
beast I'd rather not modify haha ) or creating a filter method that
will append a SQL convert function call to the select column name.
Since doing this would quite frankly "suck" I was hoping there would be
some way of telling the dataset to use the SqlDateTime thus persisting
the precision.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.