I have a Stored Procedure here:
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
This procedure works fine, unless I have umlauts in my data. Then it is messing up the input. For instance, it looks like this after the insert:
Begrüßung
This is obviously wrong. I tried to check the MSDN-Page here, which in fact describes the problem. However, not in a stored procedure. I also tried to add N'
to my variables, but that obviously lead to having a string (instead of the actual value).
My current charset for the table is: SQL_Latin1_General_CP1_CI_AS
I tried changing the type for frage to varchar(255), which didn't help, removed the N'
again.. but nothing did the trick. While checking the data in my browser, the SQL-statement is correct. It mus be while inserting it.
This is how I try to insert my data in asp-classic
SQL = "EXEC PRC_THEKE_FRAGE_INSERT '" & request("question") & "'," & request("active") & ", " & request("categoryID") & ", '" & request("sgi") & "'"
conn.execute SQL
(I know, not sanitizing right now and I shouldn't do this. Please don't tell that now :) )
Update
Header in my actual 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" />
File with my stored procedure:
'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()
%>