存储过程中的表示参数 (asp)

Denoted parameter in stored procedure (asp)

我这里有一个存储过程:

USE [RK]
GO
/****** Object:  StoredProcedure [dbo].[PRC_THEKE_FRAGE_INSERT]    Script Date: 03/09/2017 17:43:34 ******/
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
ALTER PROCEDURE [dbo].[PRC_THEKE_FRAGE_INSERT] @frage nvarchar(255),@status bit, @kategorieID tinyint, @sgi nvarchar(8)
AS

-- Neuen Datensatz speichern
INSERT INTO LLThekeFragen SELECT @frage, @status, @kategorieId, @sgi

这个程序工作正常,除非我的数据中有变音符号。然后它弄乱了输入。例如,插入后看起来像这样:

Begrüßung

这显然是错误的。我试着检查这里的 MSDN-Page ,这实际上描述了问题。但是,不是在存储过程中。我还尝试将 N' 添加到我的变量中,但这显然会导致有一个字符串(而不是实际值)。

我当前 table 的字符集是:SQL_Latin1_General_CP1_CI_AS

我尝试将 frage 的类型更改为 varchar(255),这没有帮助,我再次删除了 N' .. 但没有任何效果。在我的浏览器中检查数据时,SQL-statement 是正确的。一定是插入的时候。

这就是我尝试将数据插入 asp-classic

的方式
SQL = "EXEC PRC_THEKE_FRAGE_INSERT '" & request("question") & "'," & request("active") & ", " & request("categoryID") & ", '" & request("sgi") & "'"
conn.execute SQL

(我知道,现在没有消毒,我不应该这样做。请不要现在告诉我:))

更新

Header 在我的实际 asp-file:

Very first line of my code:
<%@ LANGUAGE="VBSCRIPT" CODEPAGE="65001" %>

in my <head>-area:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

包含我的存储过程的文件:

'this indeed did the trick - had it in the wrong file
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001" %>

<%
dim conn,SQL
set conn = Server.CreateObject("ADODB.Connection")

'open DB connection
conn.open "DSN=well;UID=rk;PWD=wellwell"

SQL = "EXEC PRC_THEKE_FRAGE_INSERT N'" & request("question") & "'," & request("active") & ", " & request("categoryID") & ", '" & request("sgi") & "'"
conn.execute SQL

conn.close()

%>

确保将其包含在页面的最顶部。

<%@Language="VBScript" CodePage = 65001 %>
<% 
  Response.CharSet = "UTF-8"
  Response.CodePage = 65001
%>

或使用此处所述的包含文件:


使用带有 adVarWChar 个参数的参数化查询
或敞开心扉 sql-injection 并在连接字符串之前添加 N

SQL = "EXEC PRC_THEKE_FRAGE_INSERT N'" & request("question") & "'," & request("active") & ", " & request("categoryID") & ", N'" & request("sgi") & "'"
conn.execute SQL