Date not saving in right format vb6.0, SQL server 2005(日期未以正确格式保存 vb6.0、SQL Server 2005)
问题描述
我试图在 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:日期未以正确格式保存 vb6.0、SQL Server 2005


基础教程推荐
- Sql Server 字符串到日期的转换 2021-01-01
- SQL Server:只有 GROUP BY 中的最后一个条目 2021-01-01
- SQL Server 2016更改对象所有者 2022-01-01
- 在 VB.NET 中更新 SQL Server DateTime 列 2021-01-01
- 将数据从 MS SQL 迁移到 PostgreSQL? 2022-01-01
- 无法在 ubuntu 中启动 mysql 服务器 2021-01-01
- 使用pyodbc“不安全"的Python多处理和数据库访问? 2022-01-01
- SQL Server 中单行 MERGE/upsert 的语法 2021-01-01
- ERROR 2006 (HY000): MySQL 服务器已经消失 2021-01-01
- 如何在 SQL Server 的嵌套过程中处理事务? 2021-01-01