#附近的语法错误 [英] incorrect syntax near #

查看:110
本文介绍了#附近的语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

da = New SqlDataAdapter("Select token_no from billentry where billdate= #" & Today & "#", myconn)

推荐答案

尝试将#替换为'

#是Visual Basic而不是SQL的日期分隔符。



更好的是,按照专业程序员的方式来做。

使用 SQLParameter 类以日期类型格式存储今天的值,并构造您的SQL语句以利用 SQLParameter 对象中的参数值。这样做可以防止那些使用SQL注入技术删除或更改数据库的恶意事件。
Try replacing # with '
# is a date delimiter for Visual Basic not SQL.

Better yet, do it the way a professional programmer would.
Use the SQLParameter Class to store the value of Today in Date Type format and construct your SQL statement to utilize the parameter value in the SQLParameter object. Doing so prevents those intent on doing evil things from using the SQL Injection technique to erase or alter your database.


使用如下参数



use parameters like below

da = New SqlDataAdapter("Select token_no from billentry where billdate= @billdate", myconn)
adapter.SelectCommand.Parameters.Add("@billdate", _
          SqlDbType.DateTime, 0,Today)







给我参数化的SQL,或者给我死亡 [ ^ ]


da =新的SqlDataAdapter(从billentry wh中选择token_no ere billdate ='+ Today +',myconn)
da = New SqlDataAdapter("Select token_no from billentry where billdate='" + Today + "'", myconn)


这篇关于#附近的语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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