M
Mark
Hi...
We're in the process of trying to internationalize our databases, converting
a lot of columns to nvarchar and the like. We just came across an odd
phenomenon with ado.net; that is passing parameters of type string get
processed correctly but executing strings of sql with literal appear to be
getting mangled/accents stripped before it gets to the sql server side.
We wrote a little sample - a db with a VARCHAR(50) column and an
NVARCHAR(50) column, a little sproc that just does an insert and 2 calls:
SqlCommand scmd = new SqlCommand("TESTINSERT", sx);
SqlParameter sqp;
sqp = new SqlParameter("@VC", "1ĞŞİışğ"); // gets accents stripped
scmd.Parameters.Add(sqp);
sqp = new SqlParameter("@NC", "1ĞŞİışğ"); // preserves accents
scmd.Parameters.Add(sqp);
scmd.CommandType = System.Data.CommandType.StoredProcedure;
scmd.ExecuteNonQuery();
scmd = new SqlCommand("TESTINSERT '2ĞŞİışğ', '2ĞŞİışğ'", sx);
scmd.ExecuteNonQuery(); // both columns have all accents stripped
Is there any way to control how ADO.Net is going to treat the literals?
Thanks
Mark
We're in the process of trying to internationalize our databases, converting
a lot of columns to nvarchar and the like. We just came across an odd
phenomenon with ado.net; that is passing parameters of type string get
processed correctly but executing strings of sql with literal appear to be
getting mangled/accents stripped before it gets to the sql server side.
We wrote a little sample - a db with a VARCHAR(50) column and an
NVARCHAR(50) column, a little sproc that just does an insert and 2 calls:
SqlCommand scmd = new SqlCommand("TESTINSERT", sx);
SqlParameter sqp;
sqp = new SqlParameter("@VC", "1ĞŞİışğ"); // gets accents stripped
scmd.Parameters.Add(sqp);
sqp = new SqlParameter("@NC", "1ĞŞİışğ"); // preserves accents
scmd.Parameters.Add(sqp);
scmd.CommandType = System.Data.CommandType.StoredProcedure;
scmd.ExecuteNonQuery();
scmd = new SqlCommand("TESTINSERT '2ĞŞİışğ', '2ĞŞİışğ'", sx);
scmd.ExecuteNonQuery(); // both columns have all accents stripped
Is there any way to control how ADO.Net is going to treat the literals?
Thanks
Mark