为了账号安全,请及时绑定邮箱和手机立即绑定

从日期时间到字符串格式的转换错误

从日期时间到字符串格式的转换错误

C#
慕姐8265434 2021-05-04 04:24:04
我对这部分代码有疑问,我正在尝试在预订表中插入一条记录。我试图输入的值是(6,3,3,20/06/2018 00:00:00,400,2800.00,True,560.00)        public void insertBooking(int bookingID, int customerID, int entertainmentID,                                   DateTime bookingDate, int numberOfGuests, double price,                                   bool deposit, decimal depositPrice)        {            db.Cmd = db.Conn.CreateCommand();            db.Cmd.CommandText = "INSERT INTO Booking (bookingID, customerID, entertainmentID,                                   [Booking Date], [Number Of Guests], [Price], [Deposit?],                                   [Deposit Price]) " + "Values ('" + bookingID + "','" +                                   customerID + "','" + entertainmentID + "','" +                                   bookingDate + "','" + numberOfGuests + "','" + price +                                   "','" + deposit + "','" + depositPrice + "')";            db.Cmd.ExecuteNonQuery();        }我收到的错误如下,“从字符串转换日期和/或时间时转换失败。”我已尽力研究此问题,但我不知道如何解决此问题。任何帮助表示赞赏。
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 122 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信