I have a MySQL database with a certain field that contains a date.
How can I convert it to a C# DateTime object?
And how do I convert a C# DateTime object so I can insert it to the database?
解决方案
You'll need the MySQL Connector for .NET, if you don't already have it, in order to get your C# application talking to MySQL.
Then you'll be able to get the date columns out of your database and into DateTime objects in the standard way, using MySqlConnection, MySqlCommand, MySqlDataReader etc.
There are a few potential gotchas when converting between MySQL dates/times and .NET DateTimes, but there's a useful section in the MySQL documentation with advice on how to handle the issues.