本文介紹了日期未以正確格式保存 vb6.0、SQL Server 2005的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!
問題描述
限時送ChatGPT賬號..
我試圖在 sql server 2005 中保存這個日期格式,我得到的只是 1/1/1900 12:00:00 AM代碼是
I am trying to save this Date format in sql server 2005, all i get is 1/1/1900 12:00:00 AM the code is
txtRent_Date.Text = Format(Now, "mm/dd/yyyy")
推薦答案
您需要在日期周圍加上撇號,如下所示:
You need to put apostrophes around your dates, like this:
strsql = "INSERT INTO Rental_Copies(Rental_id,Copies_id,Rent_Date,Due_Date)" & _
"Values(" & txtID.Text & "," & ListView1.ListItems(X + 1) & ",'" & _
txtRent_Date.Text & "','" & txtDue_Date.Text & "')"
正如其他人所說,您應(yīng)該在使用數(shù)據(jù)之前驗(yàn)證數(shù)據(jù)并參數(shù)化您的 SQL 以防止 SQL 注入.
Like others have said, you should be validating your data before using it and parameterizing your SQL to prevent SQL injection.
這篇關(guān)于日期未以正確格式保存 vb6.0、SQL Server 2005的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!