format string in datetime c# to insert in MYSQL datetime column

后端 未结 4 567
一向
一向 2020-12-16 03:27

I have code like this:

AutoParkDataDataContext Db = new AutoParkDataDataContext();
Dailyreport dailyRep = new Dailyreport();
string time = Convert.ToDateTime         


        
4条回答
  •  一个人的身影
    2020-12-16 03:37

    Your line:

    string time = Convert.ToDateTime("10-10-2014 15:00:00");
    

    Shouldn't compile.

    I can only guess that you don't have DateTime as type of your column in SQL Server, you should modify it to keep DateTime and then pass a DateTime type object, not a string.

提交回复
热议问题