久久久久久久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)(將月份名稱轉換為日期/月份編號(問題和答案的組合))
主站蜘蛛池模板: 蜜桃精品视频在线 | 中文字幕视频在线观看免费 | 亚洲视频一区二区 | 国产三级精品三级在线观看四季网 | 久久久夜色精品亚洲 | 久久综合伊人一区二区三 | 色综合99 | 一区二区三区精品在线 | 玖玖视频国产 | 国产欧美在线观看 | 一区中文 | 亚洲精品福利在线 | 婷婷五月色综合香五月 | 亚洲国产精品视频 | 综合久 | 国产中文字幕网 | 亚洲福利网 | 青青草视频网站 | 国产欧美一区二区三区另类精品 | 久久er精品| 欧美日韩亚 | 日本中文字幕日韩精品免费 | 免费久久网 | 国产xxxx岁13xxxxhd| 免费看淫片| 一区二区三区精品 | 久久av综合| 日本一区二区不卡 | 精品免费国产一区二区三区四区介绍 | www国产亚洲精品 | 国产精品69毛片高清亚洲 | 天天久久| 国产高潮av | 日韩成人在线观看 | 午夜寂寞福利视频 | 91av在线视频观看 | 综合网中文字幕 | 欧美另类视频在线 | 黄色一级大片在线免费看产 | 亚洲欧美综合 | 日韩一区欧美一区 |