pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

    • <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="vjxnpxb" 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 參數(shù)化查詢

        ADO Parameterized Queries with Subqueries Error(帶有子查詢錯誤的 ADO 參數(shù)化查詢)
        <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="xlz7tf7" 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 參數(shù)化查詢的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  限時送ChatGPT賬號..

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

                  鑒于此,我認為將其切換為參數(shù)化查詢會非常簡單.初始測試看起來不錯,一切似乎都正常工作,直到我在子查詢中遇到了帶有參數(shù)的 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"))
                  

                  沒問題,這會按預(yù)期返回 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語法錯誤、權(quán)限違規(guī)或其他非特定錯誤

                  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.

                  是否有任何解釋為什么將參數(shù)放入子查詢會導(dǎo)致參數(shù)集合出現(xiàn)問題?我確實嘗試將參數(shù)手動添加到 Parameters 集合中,效果很好,但這意味著要修改數(shù)百個現(xiàn)有的 sql 調(diào)用,因此目前 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))

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

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

                  相關(guān)文檔推薦

                  Can I figure out a list of databases and the space used by SQL Server instances without writing SQL queries?(我可以在不編寫 SQL 查詢的情況下找出數(shù)據(jù)庫列表和 SQL Server 實例使用的空間嗎?) - IT屋-程序員軟件開發(fā)
                  How to create a login to a SQL Server instance?(如何創(chuàng)建對 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()?(為什么會出現(xiàn)“數(shù)據(jù)類型轉(zhuǎn)換錯誤?使用 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 應(yīng)用程序設(shè)計——將文檔從 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="zxnr5rv" 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>
                          • 主站蜘蛛池模板: 快速门厂家批发_PVC快速卷帘门_高速门_高速卷帘门-广州万盛门业 快干水泥|桥梁伸缩缝止水胶|伸缩缝装置生产厂家-广东广航交通科技有限公司 | 浙江宝泉阀门有限公司| 【直乐】河北石家庄脊柱侧弯医院_治疗椎间盘突出哪家医院好_骨科脊柱外科专业医院_治疗抽动症/关节病骨伤权威医院|排行-直乐矫形中医医院 | 湖州织里童装_女童男童中大童装_款式多尺码全_织里儿童网【官网】-嘉兴嘉乐网络科技有限公司 | 讲师宝经纪-专业培训机构师资供应商_培训机构找讲师、培训师、讲师经纪就上讲师宝经纪 | IWIS链条代理-ALPS耦合透镜-硅烷预处理剂-上海顶楚电子有限公司 lcd条形屏-液晶长条屏-户外广告屏-条形智能显示屏-深圳市条形智能电子有限公司 | 创富网-B2B网站|供求信息网|b2b平台|专业电子商务网站 | 斗式提升机,斗式提升机厂家-淄博宏建机械有限公司 | 刹车盘机床-刹车盘生产线-龙口亨嘉智能装备 | 天津仓库出租网-天津电商仓库-天津云仓一件代发-【博程云仓】 | 悬浮拼装地板_幼儿园_篮球场_悬浮拼接地板-山东悬浮拼装地板厂家 | 海峰资讯 - 专注装饰公司营销型网站建设和网络营销培训 | 猎头招聘_深圳猎头公司_知名猎头公司 | 浙江建筑资质代办_二级房建_市政_电力_安许_劳务资质办理公司 | 通风气楼_通风天窗_屋顶风机-山东美创通风设备有限公司 | 硬齿面减速机_厂家-山东安吉富传动设备股份有限公司 | 电动百叶窗,开窗器,电动遮阳百叶,电动开窗机生产厂家-徐州鑫友工控科技发展有限公司 | 沈阳液压泵_沈阳液压阀_沈阳液压站-沈阳海德太科液压设备有限公司 | 瓶盖扭矩测试仪-瓶盖扭力仪-全自动扭矩仪-济南三泉中石单品站 | 运动木地板_体育木地板_篮球馆木地板_舞台木地板-实木运动地板厂家 | PSI渗透压仪,TPS酸度计,美国CHAI PCR仪,渗透压仪厂家_价格,微生物快速检测仪-华泰和合(北京)商贸有限公司 | 氟塑料磁力泵-不锈钢离心泵-耐腐蚀化工泵厂家「皖金泵阀」 | 沈阳缠绕包装机厂家直销-沈阳海鹞托盘缠绕包装机价格 | 水冷式工业冷水机组_风冷式工业冷水机_水冷螺杆冷冻机组-深圳市普威机械设备有限公司 | 胀套-锁紧盘-风电锁紧盘-蛇形联轴器「厂家」-瑞安市宝德隆机械配件有限公司 | 博莱特空压机|博莱特-阿特拉斯独资空压机品牌核心代理商 | 深圳VI设计-画册设计-LOGO设计-包装设计-品牌策划公司-[智睿画册设计公司] | 药品/药物稳定性试验考察箱-埃里森仪器设备(上海)有限公司 | 附着力促进剂-尼龙处理剂-PP处理剂-金属附着力处理剂-东莞市炅盛塑胶科技有限公司 | 工业CT-无锡璟能智能仪器有限公司| NBA直播_NBA直播免费观看直播在线_NBA直播免费高清无插件在线观看-24直播网 | 无水硫酸铝,硫酸铝厂家-淄博双赢新材料科技有限公司 | 建筑消防设施检测系统检测箱-电梯**检测仪器箱-北京宇成伟业科技有限责任公司 | 南汇8424西瓜_南汇玉菇甜瓜-南汇水蜜桃价格 | 成都装修公司-成都装修设计公司推荐-成都朗煜装饰公司 | 环讯传媒,永康网络公司,永康网站建设,永康小程序开发制作,永康网站制作,武义网页设计,金华地区网站SEO优化推广 - 永康市环讯电子商务有限公司 | 集装袋吨袋生产厂家-噸袋廠傢-塑料编织袋-纸塑复合袋-二手吨袋-太空袋-曹县建烨包装 | 苏州注册公司_苏州代理记账_苏州工商注册_苏州代办公司-恒佳财税 | 广州展览制作|展台制作工厂|展览设计制作|展览展示制作|搭建制作公司 | 深圳美安可自动化设备有限公司,喷码机,定制喷码机,二维码喷码机,深圳喷码机,纸箱喷码机,东莞喷码机 UV喷码机,日期喷码机,鸡蛋喷码机,管芯喷码机,管内壁喷码机,喷码机厂家 | 塑木弯曲试验机_铜带拉伸强度试验机_拉压力测试台-倾技百科 |