安全的DateTime在T-SQL INSERT语句 [英] Safe DateTime in a T-SQL INSERT statement

查看:146
本文介绍了安全的DateTime在T-SQL INSERT语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一直问题在T-SQL INSERT INTO语句中使用日期时间运行最近。一台机器上正常工作,但可能没有其他工作,我想这与区域设置有关。

Been running in problem lately with using a DateTime in a T-SQL INSERT INTO statement. Work fine on one machine but might not work on another and I guess this has to do with locale settings.

所以,如果我有日期时间变量的是使用在一个字符串的SQLStatement的安全方式,它会一直在本地系统设置,无论工作?

So if I have DateTime variable what is the safe way of using that in a SqlStatement string that it will always work regardless on local system settings?

感谢

推荐答案

使用<一个href=\"http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.parameters%28v=VS.100%29.aspx\"相对=nofollow>参数 插入查询。

最有可能的,你的code为组装的SQL命令字符串。这也使您的code容易 SQL注入

Most likely, your code is assembling the SQL command string. That also makes your code vulnerable to SQL Injection.

这篇关于安全的DateTime在T-SQL INSERT语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆