Access db problem from .NET

L

Lars Netzel

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
 
C

Cor Ligthert

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
 
L

Lars Netzel

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
 
C

Cor Ligthert

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).ToString)
///
They both give the same date and time,

What do I not understand?

Cor
 
L

Lars Netzel

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top