[Mono-list] CodePage problem unixODBC+FreeTDS+MS SQL
Irbis
ounces at yandex.ru
Mon Jul 13 18:27:24 UTC 2015
Problem with non-english symbol. From SQL Profiler:
SELECT * FROM Table WHERE Col1 = 'qwerty9FC:5=' - after symbols qwerty wrong
symbols
===========================================
using System;
using System.Data;
using System.Data.Common;
using System.Data.Odbc;
namespace TestCP
{
class MainClass
{
public static void Main (string[] args)
{
string connectionString = "DSN=TMS;UID=USER;Pwd=PWD;APP=Test;";
string sql = "SELECT * FROM Table WHERE Col1 = 'qwertyйцукен'";
try
{
OdbcConnection conn = new OdbcConnection(connectionString);
conn.Open();
Console.WriteLine(sql);
OdbcCommand comm = new OdbcCommand(sql, conn);
try
{
comm.ExecuteNonQuery();
}
catch(Exception e)
{
}
comm.Dispose();
sql = "SELECT * FROM Table WHERE Col1 = ?";
OdbcParameter p1 = new OdbcParameter("p1", OdbcType.VarChar);
p1.Value = "qwertyйцукен";
//OdbcParameter p2 = new OdbcParameter("p2", OdbcType.NVarChar);
//p2.Value = "qwertyйцукен";
comm = new OdbcCommand(sql, conn);
comm.Parameters.Add(p1);
//comm.Parameters.Add(p2);
try
{
OdbcDataReader dr = comm.ExecuteReader();
}
catch(Exception e)
{
}
conn.Close();
comm.Dispose();
conn.Dispose();
}
catch(Exception e)
{
}
}
}
}
===========================================
Second query:
declare @p1 int
set @p1=NULL
exec sp_prepexec @p1 output,N'@P1 VARCHAR(18)',N'SELECT * FROM Table WHERE
Col1 = @P1','qwertyйцукен'
select @p1
- all symbols ok.
When run from .Net
SELECT * FROM Table WHERE Col1 = 'qwertyйцукен'
exec sp_executesql N'SELECT * FROM Table WHERE Col1 = @P1',N'@P1
varchar(13)','qwertyйцукен'
- all query ok.
ODBC.INI
[TMS]
Driver=FreeTDS
Database=TMS
Server=local
TDS_Version=7.0
ClientCharset=UTF-16
ODBCINST.INI
[FreeTDS]
Driver=/usr/lib/i386-linux-gnu/odbc/libtdsodbc.so
Threading=1
Debian 8.1, Mono Stable 4.0.2.5
--
View this message in context: http://mono.1490590.n4.nabble.com/CodePage-problem-unixODBC-FreeTDS-MS-SQL-tp4666333.html
Sent from the Mono - General mailing list archive at Nabble.com.
More information about the Mono-list
mailing list