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

在參數(shù)中調(diào)用帶有撇號的存儲過程不起作用

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

問題描述

我有一個 C# 應(yīng)用程序,它的部分工作是將 Excel 文件中的所有數(shù)據(jù)插入到數(shù)據(jù)庫中.

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 獲取數(shù)據(jù)的工作沒問題,我正在使用存儲過程將數(shù)據(jù)插入數(shù)據(jù)庫中的表中.

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'

當(dāng)我遇到這樣的情況時就會出現(xiàn)問題:

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'

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

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 中獲取一行后,我使用循環(huán)將參數(shù)放入作為查詢的字符串中.

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

推薦答案

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

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'

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

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

相關(guān)文檔推薦

Converting Every Child Tags in to a Single Column with multiple Delimiters -SQL Server (3)(將每個子標(biāo)記轉(zhuǎn)換為具有多個分隔符的單列-SQL Server (3))
How can I create a view from more than one table?(如何從多個表創(chuàng)建視圖?)
Create calculated value based on calculated value inside previous row(根據(jù)前一行內(nèi)的計算值創(chuàng)建計算值)
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屋-程序員軟件開發(fā)技
Recursive t-sql query(遞歸 t-sql 查詢)
Convert Month Name to Date / Month Number (Combinations of Questions amp; Answers)(將月份名稱轉(zhuǎn)換為日期/月份編號(問題和答案的組合))
主站蜘蛛池模板: 天堂一区在线观看 | 99re在线视频 | 成人一区二区在线 | 成人av在线播放 | 久久国产精品视频 | 亚洲在线电影 | 精品国产欧美在线 | 成人日批视频 | 亚洲欧洲成人 | 91中文字幕在线观看 | 国产精品久久久久久久久动漫 | 一区二区三区四区免费在线观看 | 91麻豆精品一区二区三区 | 一区二区在线不卡 | 欧美色综合天天久久综合精品 | 国产黄色网址在线观看 | 在线日韩欧美 | 91精品国产乱码久久久久久久久 | 欧美一级在线 | 日韩成人高清 | 黄视频网站在线 | 高清国产午夜精品久久久久久 | 美女视频三区 | 亚洲一区二区中文字幕在线观看 | 国产精品九九九 | 亚洲欧美网站 | a久久 | 国产精品久久久久aaaa九色 | 欧美女优在线观看 | 91视频一区二区 | 精品久久一 | 国产激情视频在线免费观看 | 色婷婷综合网 | 午夜国产在线 | 犬夜叉在线观看 | 91视视频在线观看入口直接观看 | 一区二区精品视频 | 国产一区欧美 | 欧美日韩国产一区二区三区 | 黄色片视频| 国产精品乱码一区二三区小蝌蚪 |