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

在參數中調用帶有撇號的存儲過程不起作用

calling stored procedure with apostrophe in argument doesn#39;t work(在參數中調用帶有撇號的存儲過程不起作用)
本文介紹了在參數中調用帶有撇號的存儲過程不起作用的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我有一個 C# 應用程序,它的部分工作是將 Excel 文件中的所有數據插入到數據庫中.

I have an app in C# when part of its job is to insert all the data from an Excel file to a database.

從 Excel 獲取數據的工作沒問題,我正在使用存儲過程將數據插入數據庫中的表中.

The job of getting the data from Excel is alright, and I am using stored procedures to insert the data into the tables in the DB.

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER Procedure [dbo].[sp_Insert]

@id int,
@brand nvarchar(50),
@model nvarchar(50),
@prodNumber nvarchar(50),
@category nvarchar(50),
@local nvarchar(50)

AS
INSERT INTO Tbl_Registos (ID, Brand, Model, [Product Number], Category, Local)
VALUES (@id, @brand, @model, @prodNumber, @category, @local)

這是一個 SP 完美運行的例子:

This is one example when the SP works perfectly:

sp_Insert N'1', N'Brand example', N'ABC123', N'123456-7890', 
          N'Laptop', N'18'

當我遇到這樣的情況時就會出現問題:

The problem comes when I have cases like this:

sp_Insert N'1', N'Brand example', N'ABC123', N'123456-7890',
          N'Laptop', N'Director's floor'

當我在參數中間有這個 ' 時.我想使用引號 [],但在我有整數的情況下,我不能將它們放在引號之間.

When I have this ' in the middle of the argument. I thought to use quotes [], but in cases where I have integers, I can't put them between quotes.

從 Excel 中獲取一行后,我使用循環將參數放入作為查詢的字符串中.

After I got a row from Excel, I am using a loop to put the arguments in the string that is the query.

推薦答案

您可以通過在輸入中放置另一個 ' 來對輸入中的 ' 進行轉義,并且插入將起作用.您可以執行此操作,也可以解析此類字符的數據并忽略它們.因此,帶有此轉義符的插入語句將是:

You can escape the ' in your input by putting another ' in front of it and the insert will work. You can either do this or parse the data for characters like this and disregard them. So your insert statement with this escaped would be:

sp_Insert N'1', N'Brand example', N'ABC123', N'123456-7890', N'Laptop', N'Director''s floor'

這篇關于在參數中調用帶有撇號的存儲過程不起作用的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

Converting Every Child Tags in to a Single Column with multiple Delimiters -SQL Server (3)(將每個子標記轉換為具有多個分隔符的單列-SQL Server (3))
How can I create a view from more than one table?(如何從多個表創建視圖?)
Create calculated value based on calculated value inside previous row(根據前一行內的計算值創建計算值)
How do I stack the first two columns of a table into a single column, but also pair third column with the first column only?(如何將表格的前兩列堆疊成一列,但也僅將第三列與第一列配對?) - IT屋-程序員軟件開發技
Recursive t-sql query(遞歸 t-sql 查詢)
Convert Month Name to Date / Month Number (Combinations of Questions amp; Answers)(將月份名稱轉換為日期/月份編號(問題和答案的組合))
主站蜘蛛池模板: 日韩欧美久久精品 | 国产成人av在线播放 | 亚洲一区二区三区在线播放 | 91国内视频在线 | 日韩成人在线播放 | 婷婷色网| 一级黄色毛片a | 国产成人精品综合 | 黄色一级片aaa | 国产一二三区精品视频 | 欧美色综合 | 国产日韩精品视频 | 亚洲国产精品成人综合久久久 | 毛片黄 | 国产视频二区在线观看 | www.一区二区三区 | 欧美亚洲在线 | www.色综合| 免费毛片在线 | av成年人网站 | 91青娱乐在线 | 精久久久| 亚洲精品3 | 日本一二区视频 | 亚洲欧洲在线视频 | 欧美精品一区二区在线观看 | 91视频三区 | 欧美三级网站 | 亚洲精品永久免费 | 中文在线播放 | 91中文字幕| 九九伊人sl水蜜桃色推荐 | 91在线看片 | 祝你幸福电影在线观看 | 久久一二 | 日韩一区二区在线播放 | 久久久久亚洲精品 | 在线看日韩av | 久久精品中文 | 日本一区二区三区精品视频 | 91久色|