I'm using stored procedures and DataContext to insert data to SQL Server database (ASP.NET 4 + SQL Server 2005 database, GoDaddy hosting)
But after inserting russian text I see smth like this - '??????'
If I insert constant text I'm using following construction - N'russian_text'
and it w开发者_如何学Corks fine.
Of course, I need to use variables as procedure parameters BUT I can't use it (for example - N@var fails)
ALTHOUGH I'm using N-type fields in tables (nvarchar
etc.)
Does anybody knows where is mistake?
NVARCHAR variables are declared as
DECLARE @var NVARCHAR(100)
SET @var = N'unicode text'
and not as DECLARE N@var..., SET N@var
Same applies to procedure and function parameters
CREATE PROCEDURE InsertUnicodeData( @data NVARCHAR(200) ) AS
....
your SqlParamter variables in .net need to be of type SqlDbType.NVarChar.
as is now they're SqlDbType.VarChar.
in sql server your @text needs to be nvarchar(ColLength)
精彩评论