久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    • <bdo id='mtFp0'></bdo><ul id='mtFp0'></ul>
  • <i id='mtFp0'><tr id='mtFp0'><dt id='mtFp0'><q id='mtFp0'><span id='mtFp0'><b id='mtFp0'><form id='mtFp0'><ins id='mtFp0'></ins><ul id='mtFp0'></ul><sub id='mtFp0'></sub></form><legend id='mtFp0'></legend><bdo id='mtFp0'><pre id='mtFp0'><center id='mtFp0'></center></pre></bdo></b><th id='mtFp0'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='mtFp0'><tfoot id='mtFp0'></tfoot><dl id='mtFp0'><fieldset id='mtFp0'></fieldset></dl></div>

    <small id='mtFp0'></small><noframes id='mtFp0'>

    1. <legend id='mtFp0'><style id='mtFp0'><dir id='mtFp0'><q id='mtFp0'></q></dir></style></legend>

        <tfoot id='mtFp0'></tfoot>

        帶有子查詢錯誤的 ADO 參數化查詢

        ADO Parameterized Queries with Subqueries Error(帶有子查詢錯誤的 ADO 參數化查詢)
        <i id='VHX9N'><tr id='VHX9N'><dt id='VHX9N'><q id='VHX9N'><span id='VHX9N'><b id='VHX9N'><form id='VHX9N'><ins id='VHX9N'></ins><ul id='VHX9N'></ul><sub id='VHX9N'></sub></form><legend id='VHX9N'></legend><bdo id='VHX9N'><pre id='VHX9N'><center id='VHX9N'></center></pre></bdo></b><th id='VHX9N'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='VHX9N'><tfoot id='VHX9N'></tfoot><dl id='VHX9N'><fieldset id='VHX9N'></fieldset></dl></div>

          <tbody id='VHX9N'></tbody>

            <tfoot id='VHX9N'></tfoot>

                <bdo id='VHX9N'></bdo><ul id='VHX9N'></ul>

                  <small id='VHX9N'></small><noframes id='VHX9N'>

                  <legend id='VHX9N'><style id='VHX9N'><dir id='VHX9N'><q id='VHX9N'></q></dir></style></legend>
                • 本文介紹了帶有子查詢錯誤的 ADO 參數化查詢的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我有一個運行 SQL Server 2012(也用 2016 測試)的舊版經典 ASP 應用程序,我正在嘗試切換到使用參數化查詢.該站點的所有查詢都通過一個函數運行,該函數將 sql 語句視為字符串,其中包含由問號表示的參數以及這些參數的數組.該函數目前對參數進行過濾,使它們成為 sql 安全的,并在執行語句之前將它們放入 sql 字符串中.

                  I have a legacy classic ASP application running with SQL Server 2012 (also tested with 2016) that I am trying to switch over to using parameterized queries. All the site's queries run through a function which expects a sql statement as a string with parameters represented by question marks as well as an array of those parameters. The function currently filters the parameters to make them sql safe and puts them into the sql string before executing the statement.

                  鑒于此,我認為將其切換為參數化查詢會非常簡單.初始測試看起來不錯,一切似乎都正常工作,直到我在子查詢中遇到了帶有參數的 sql 語句.

                  Given this, I thought it would be pretty straightforward to switch this to parameterized queries. Initial testing looked good, and everything appeared to be working properly until I hit a sql statement with parameters in subqueries.

                  以下是有效的測試示例:

                  Here's a test sample of what works:

                  Const connectionString = "Provider=SQLNCLI11; Server=********; Database=********; UID=*******; PWD=*******"
                  
                  Dim sql, productId, parameters
                  sql = "SELECT SKU FROM Products WHERE ProductId = ?"
                  productId = 3
                  parameters = Array(productId)
                  
                  Dim conn
                  Set conn = Server.CreateObject("ADODB.Connection")
                  conn.Open connectionString
                  
                  Dim cmd
                  Set cmd = Server.CreateObject("ADODB.Command")
                  cmd.ActiveConnection = conn
                  cmd.CommandText = sql
                  cmd.Parameters.Refresh
                  
                  Dim rs
                  Set rs = cmd.Execute(, parameters)
                  
                  Response.Write("SKU: " & rs("SKU"))
                  

                  沒問題,這會按預期返回 SKU.但是,如果我使用子查詢:

                  No problem, this returns the SKU as expected. However, if I use a subquery:

                  Const connectionString = "Provider=SQLNCLI11; Server=********; Database=********; UID=*******; PWD=*******"
                  
                  Dim sql, productId, parameters
                  'contrived subquery for demonstration purposes
                  sql = "SELECT SKU FROM ( SELECT SKU FROM Products WHERE ProductId = ? ) AS P"
                  productId = 3
                  parameters = Array(productId)
                  
                  Dim conn
                  Set conn = Server.CreateObject("ADODB.Connection")
                  conn.Open connectionString
                  
                  Dim cmd
                  Set cmd = Server.CreateObject("ADODB.Command")
                  cmd.ActiveConnection = conn
                  cmd.CommandText = sql
                  cmd.Parameters.Refresh
                  
                  Dim rs
                  Set rs = cmd.Execute(, parameters)
                  
                  Response.Write("SKU: " & rs("SKU"))
                  

                  它在 cmd.Parameters.Refresh 行拋出錯誤:

                  It throws an error on the cmd.Parameters.Refresh line:

                  Microsoft VBScript 運行時錯誤0x80004005"Microsoft SQL Server 本機客戶端 11.0語法錯誤、權限違規或其他非特定錯誤

                  Microsoft VBScript runtime error '0x80004005' Microsoft SQL Server Native Client 11.0 Syntax error, permission violation, or other nonspecific error

                  如果我在第一個樣本中檢查 cmd.Parameters.Count,我會正確地得到 1.在錯誤的樣本中,它會拋出相同的錯誤.

                  If I check cmd.Parameters.Count in the first sample, I correctly get 1. In the bad sample it throws the same error.

                  是否有任何解釋為什么將參數放入子查詢會導致參數集合出現問題?我確實嘗試將參數手動添加到 Parameters 集合中,效果很好,但這意味著要修改數百個現有的 sql 調用,因此目前 cmd.Parameters.Refresh 往返是值得的.

                  Is there any explanation as to why putting the parameter into a subquery causes problems with the parameter collection? I did try manually adding the parameter to the Parameters collection, and that works fine, but it means modifying hundreds of existing sql calls, so for the moment the cmd.Parameters.Refresh round-trip was worth the expense.

                  推薦答案

                  cmd.execute你想要什么都可以,不過我好久沒用了.

                  You can give cmd.execute what you want, but I haven't used it in a long time.

                  cmd.execute("SELECT SKU FROM ( SELECT SKU FROM Products WHERE ProductId = ? ) AS P", Array(productId))

                  cmd.execute("SELECT SKU FROM ( SELECT SKU FROM Products WHERE ProductId = ? ) AS P", Array(productId))

                  這篇關于帶有子查詢錯誤的 ADO 參數化查詢的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Can I figure out a list of databases and the space used by SQL Server instances without writing SQL queries?(我可以在不編寫 SQL 查詢的情況下找出數據庫列表和 SQL Server 實例使用的空間嗎?) - IT屋-程序員軟件開發
                  How to create a login to a SQL Server instance?(如何創建對 SQL Server 實例的登錄?)
                  How to know the version and edition of SQL Server through registry search(如何通過注冊表搜索知道SQL Server的版本和版本)
                  Why do I get a quot;data type conversion errorquot; with ExecuteNonQuery()?(為什么會出現“數據類型轉換錯誤?使用 ExecuteNonQuery()?)
                  How to show an image from a DataGridView to a PictureBox?(如何將 DataGridView 中的圖像顯示到 PictureBox?)
                  WinForms application design - moving documents from SQL Server to file storage(WinForms 應用程序設計——將文檔從 SQL Server 移動到文件存儲)
                  • <i id='Embiy'><tr id='Embiy'><dt id='Embiy'><q id='Embiy'><span id='Embiy'><b id='Embiy'><form id='Embiy'><ins id='Embiy'></ins><ul id='Embiy'></ul><sub id='Embiy'></sub></form><legend id='Embiy'></legend><bdo id='Embiy'><pre id='Embiy'><center id='Embiy'></center></pre></bdo></b><th id='Embiy'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Embiy'><tfoot id='Embiy'></tfoot><dl id='Embiy'><fieldset id='Embiy'></fieldset></dl></div>
                    <legend id='Embiy'><style id='Embiy'><dir id='Embiy'><q id='Embiy'></q></dir></style></legend>

                        <tbody id='Embiy'></tbody>

                      <small id='Embiy'></small><noframes id='Embiy'>

                          • <bdo id='Embiy'></bdo><ul id='Embiy'></ul>
                            <tfoot id='Embiy'></tfoot>
                          • 主站蜘蛛池模板: 夜夜爽99久久国产综合精品女不卡 | 亚洲精品乱码久久久久久黑人 | 狠狠操狠狠干 | 亚洲成人自拍 | 免费a大片| 在线永久看片免费的视频 | 成人二区 | 国产黄视频在线播放 | 在线观看视频91 | 国产一区二区在线播放 | 精品国产一区二区三区免费 | 国产精品高潮呻吟久久 | 99在线播放 | 久久国产精品一区 | 一级毛片视频免费观看 | 国产精品久久久久久久午夜片 | 国产乱码久久久 | 日韩一二三区视频 | 国产成人精品免费视频大全最热 | 国产一区二区三区在线视频 | 天天操夜夜操免费视频 | a级片在线观看 | www.国产精品 | 亚洲欧美国产毛片在线 | 国产一区在线免费 | 日本三级视频 | 亚洲国产精品99久久久久久久久 | 一区二区三区在线观看免费视频 | 日本一区二区高清不卡 | 在线看日韩 | 日本一区二区三区四区 | 一级高清免费毛片 | 国产视频久久久久 | 日日日操 | av在线免费观看网址 | 网站黄色在线免费观看 | 国产久视频 | 黄a免费看| 请别相信他免费喜剧电影在线观看 | 91xxx在线观看| 激情小说综合网 |