我將客戶端信息插入到VB.Net 2010的MySql數據庫中的客戶端表中。問題是當它插入日期值時,MySql日期列顯示:「0000-00-00」。保存日期和時間從VB.Net到MySQL數據庫日期?
我需要做什麼才能將兼容的日期格式插入MysQl數據庫?
這是我試圖做到這一點的代碼:要插入DateTimePicker1.MinDate
而不是用戶選擇的實際值
Dim dtb, dtr As DateTime
DateTimePicker1.Format = DateTimePickerFormat.Custom
DateTimePicker1.CustomFormat = "yyyy-mm-dd"
dtb = DateTimePicker1.MinDate
txtdtb.AppendText(dtb)
DateTimePicker2.Format = DateTimePickerFormat.Custom
DateTimePicker2.CustomFormat = "yyyy-mm-dd"
dtr = DateTimePicker1.MinDate
ExecSQL("INSERT INTO clients VALUES('" & clid.Text & "','" & clname.Text & "','" & clgen.Text & "','" & dtb & "','" & claddress.Text & "','" & clemail.Text & "','" & clphone.Text & "','" & clocp.Text & "','" & dtr & "')")
MsgBox("Record Saved", MsgBoxStyle.Information, "Save")
FillList(frmMember.lvMember, GetData("SELECT * FROM clients"))
End If
請使用參數化查詢....當然重寫後,ExecSQL – Steve