By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,034 Members | 1,247 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,034 IT Pros & Developers. It's quick & easy.

Access db problem from .NET

P: n/a
I have a small application that will copy two tables from one access databas
to another, the tables are present in the destination database and I only
copy the data over. So there is no created on the databases. I do this by
filling a DataSet and then Copy() to another Dataset and Update() the
destination Database's Adapter

Everything works fine except for ONE thing...

One field is of Date/Time type and when I copy ONLY the Date is copied over
the right way and not the time... the time turns into 00:00:00 on all the
records but the Date is correct!

for example
2004-05-24 08:10:03 will turn into -> 2004-05-24 00:00:00

Any idea what this can come of?

Best Regards
/Lars
Nov 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Hi Lars,

Not that I know the answer direct however is your copy only a

datatablenew = datatableold.copy

Or do you use another method?

Cor
Nov 20 '05 #2

P: n/a

Yes that's how I copy... but I actually copy on the Dataset level, the
dataset contains both Tables then..

So it'd be:

DatasetNew = DatasetOld.Copy()

/Lars

"Cor Ligthert" <no**********@planet.nl> skrev i meddelandet
news:e4*************@TK2MSFTNGP11.phx.gbl...
Hi Lars,

Not that I know the answer direct however is your copy only a

datatablenew = datatableold.copy

Or do you use another method?

Cor

Nov 20 '05 #3

P: n/a
Hi Lars,

I tested this
\\\
Dim ds As New DataSet
Dim dt As New DataTable
Dim dc As New DataColumn
dc.DataType = GetType(DateAndTime)
dt.Columns.Add(dc)
ds.Tables.Add(dt)
Dim dr As DataRow = dt.NewRow
dr(0) = Now
ds.Tables(0).Rows.Add(dr)
MessageBox.Show(ds.Tables(0).Rows(0)(0).ToString)
Dim dsnew As New DataSet
dsnew = ds.Copy
MessageBox.Show(dsnew.Tables(0).Rows(0)(0).ToStrin g)
///
They both give the same date and time,

What do I not understand?

Cor
Nov 20 '05 #4

P: n/a
Not sure..

In the database though the there are two fileds (of which I am NOT in charge
of designing).

"Date" and "TimeWritten"

Both are of Date/time type but in the "Date" field there's only a datevalue
when createing the record amd in the "TimeWritten" only a Timevalue is
written... I'm thinking maybe this is wrong?

What I mean is that when the record is created the "date" field get this
information "2005-05-24" while the "TimeWritten" only get "08:10:03" ....

I myself think it's unnessessarry to have two fields for this but I can't
really change that and it's a strnge error anyway..

/Lars

"Cor Ligthert" <no**********@planet.nl> skrev i meddelandet
news:ub**************@TK2MSFTNGP12.phx.gbl...
Hi Lars,

I tested this
\\\
Dim ds As New DataSet
Dim dt As New DataTable
Dim dc As New DataColumn
dc.DataType = GetType(DateAndTime)
dt.Columns.Add(dc)
ds.Tables.Add(dt)
Dim dr As DataRow = dt.NewRow
dr(0) = Now
ds.Tables(0).Rows.Add(dr)
MessageBox.Show(ds.Tables(0).Rows(0)(0).ToString)
Dim dsnew As New DataSet
dsnew = ds.Copy
MessageBox.Show(dsnew.Tables(0).Rows(0)(0).ToStrin g)
///
They both give the same date and time,

What do I not understand?

Cor

Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.