我试图在 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 & "')"
正如其他人所说,您应该在使用数据之前验证数据并参数化您的 SQL 以防止 SQL 注入.
Like others have said, you should be validating your data before using it and parameterizing your SQL to prevent SQL injection.
这篇关于日期未以正确格式保存 vb6.0、SQL Server 2005的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
我应该使用什么 SQL Server 数据类型来存储字节 What SQL Server Datatype Should I Use To Store A Byte[](我应该使用什么 SQL Server 数据类型来存储字节 [])
解释 SQL Server 中 sys.objects 中的类型代码Interpreting type codes in sys.objects in SQL Server(解释 SQL Server 中 sys.objects 中的类型代码)
Typeorm .loadRelationCountAndMap 返回零Typeorm .loadRelationCountAndMap returns zeros(Typeorm .loadRelationCountAndMap 返回零)
MS SQL:ISDATE() 是否应该返回“1"?什么时候不能MS SQL: Should ISDATE() Return quot;1quot; when Cannot Cast as Date?(MS SQL:ISDATE() 是否应该返回“1?什么时候不能投射为日期?)
将一天的名称转换为其整数表示Converting the name of a day to its integer representation(将一天的名称转换为其整数表示)
如何在 SQL Server 中将 nvarchar m/d/yy 转换为 mm/dd/yHow to convert nvarchar m/d/yy to mm/dd/yyyy in SQL Server?(如何在 SQL Server 中将 nvarchar m/d/yy 转换为 mm/dd/yyyy?)