P
Philip Poole
Hello everyone,
Last week I had one of my main hardrives fail. I have now reinstalled my
computer and loaded back all of my software and program I was developing.
I have been writing a program which connects to a database that is located
on a different computer, however my program is having lots of difficulties
loading and inserting data to the database.
After some investigation I have found it is do with the datetime format.
When using an OleDbDataReader if the reader[3] is reading upload date in the
database it now throws an exception if I try and reinsert this into another
table due to the char format. I then discovered that the reader is
autmotically converting the type to a c# datetime object if I call
reader[3].ToString().
For example, before my hardrive failure, this worked: -
string datetime = reader[2].ToString().Trim()
//before hardrive failure datetime was in the format: dd/MM/yyyy hh:mm:ss tt
//after hardrive failure datetime is now in the format: dd/MM/yyyy
hh:mm:ss:T
Now I have got to use the below: -
string UploadDate = ( (DateTime) reader[3]).ToString("dd/MM/yyyy hh:mm:ss
tt");
This means that I am left with many lines of code spread out in a very large
program that need to be rewritten. Does anyone know why this is happening
and how I can get it back to the old functionailty so I do not have rewrite
all these lines of code.
Please help
Phil
Last week I had one of my main hardrives fail. I have now reinstalled my
computer and loaded back all of my software and program I was developing.
I have been writing a program which connects to a database that is located
on a different computer, however my program is having lots of difficulties
loading and inserting data to the database.
After some investigation I have found it is do with the datetime format.
When using an OleDbDataReader if the reader[3] is reading upload date in the
database it now throws an exception if I try and reinsert this into another
table due to the char format. I then discovered that the reader is
autmotically converting the type to a c# datetime object if I call
reader[3].ToString().
For example, before my hardrive failure, this worked: -
string datetime = reader[2].ToString().Trim()
//before hardrive failure datetime was in the format: dd/MM/yyyy hh:mm:ss tt
//after hardrive failure datetime is now in the format: dd/MM/yyyy
hh:mm:ss:T
Now I have got to use the below: -
string UploadDate = ( (DateTime) reader[3]).ToString("dd/MM/yyyy hh:mm:ss
tt");
This means that I am left with many lines of code spread out in a very large
program that need to be rewritten. Does anyone know why this is happening
and how I can get it back to the old functionailty so I do not have rewrite
all these lines of code.
Please help
Phil