#错误附近的语法无效。

编程入门 行业动态 更新时间:2024-10-25 06:33:37
本文介绍了#错误附近的语法无效。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已将数据库从Access转换为SQL。因为Sql不接受format()所以它显示#附近的无效语法错误。我怎么解决这个问题。请帮帮我。 这是我的代码。 Private Sub LoadGrid() Da =新SqlDataAdapter(SELECT StudentAccountS.StClass,StudentAccountS.StAdmNo,StudentAccountS.StName,StudentAccount.Amount,StudentAccountS.Remark,StudentAccountS.ReceiptNo,StudentAccount.TransactionID,StudentAccount.Perticular FROM StudentAccountS INNER JOIN StudentAccount ON StudentAccountS.SSID = StudentAccount.SSID其中& (StudentAccountS.Dated =#&Format(SelDate,MM / dd / yyyy)&#) ,康宁) GridDT =新数据表 Da.Fill(GridDT) 结束Sub

I Have Converted my database from Access To SQL .As Sql Doesn't accept format() so it shows an error of invalid Syntax near #. How can I Solve this problem. Please help me. This is my Code. Private Sub LoadGrid() Da = New SqlDataAdapter("SELECT StudentAccountS.StClass, StudentAccountS.StAdmNo, StudentAccountS.StName, StudentAccount.Amount, StudentAccountS.Remark, StudentAccountS.ReceiptNo, StudentAccount.TransactionID,StudentAccount.Perticular FROM StudentAccountS INNER JOIN StudentAccount ON StudentAccountS.SSID = StudentAccount.SSID where " & "(StudentAccountS.Dated = #" & Format(SelDate, "MM/dd/yyyy") & "#)", Conn) GridDT = New DataTable Da.Fill(GridDT) End Sub

推荐答案

修复 SQL注入 [ ^ ]代码中的漏洞,你会同时修复此问题: Fix the SQL Injection[^] vulnerability in your code, and you'll fix this problem at the same time: Da = New SqlDataAdapter("SELECT StudentAccountS.StClass, StudentAccountS.StAdmNo, StudentAccountS.StName, StudentAccount.Amount, StudentAccountS.Remark, StudentAccountS.ReceiptNo, StudentAccount.TransactionID,StudentAccount.Perticular FROM StudentAccountS INNER JOIN StudentAccount ON StudentAccountS.SSID = StudentAccount.SSID where (StudentAccountS.Dated = @Dated)", Conn) Da.SelectCommand.Parameters.AddWithValue("@Dated", SelDate) GridDT = New DataTable Da.Fill(GridDT)

你想知道关于SQL注入的一切(但不敢问)特洛伊亨特 [ ^ ] 如何在没有技术术语的情况下解释SQL注入? |信息安全堆栈交换 [ ^ ] 查询参数化备忘单| OWASP [ ^ ] SQL注入攻击机制Pluralsight [ ^ ]

Everything you wanted to know about SQL injection (but were afraid to ask) | Troy Hunt[^] How can I explain SQL injection without technical jargon? | Information Security Stack Exchange[^] Query Parameterization Cheat Sheet | OWASP[^] SQL injection attack mechanics | Pluralsight [^]

在SQL中,您将使用 CONVERT [ ^ ]函数。 In SQL you would use the CONVERT[^] function. Da = New SqlDataAdapter("SELECT StudentAccountS.StClass, StudentAccountS.StAdmNo, StudentAccountS.StName, StudentAccount.Amount, StudentAccountS.Remark, StudentAccountS.ReceiptNo, StudentAccount.TransactionID,StudentAccount.Perticular FROM StudentAccountS INNER JOIN StudentAccount ON StudentAccountS.SSID = StudentAccount.SSID where " & "(StudentAccountS.Dated = #" & CONVERT(VARCHAR(10), SelDate, 101) & "#)", Conn)

更多推荐

#错误附近的语法无效。

本文发布于:2023-05-26 19:30:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/265234.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:语法   错误

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!