Hi,
I am inserting European language text into nvarchar column in SQL server 2008. The accented characters are not stored properly in the SQL DB.
string strData ="Accented chars- Les caract?res accentu?s fran?ais ";
DataTable dtTemp =newDataTable();
dtTemp.Columns.Add("ID",typeof(string));
dtTemp.Columns.Add("Value",typeof(string));
DataRow dr = dtTemp.NewRow();
dr["ID"]="100";
dr["Value"]= strData;
dtTemp.Rows.Add(dr);
strSQLCon =GetSQLConnectionString();
using(SqlConnection cn =newSqlConnection(strSQLCon))
{
cn.Open();
using(SqlBulkCopy copy =newSqlBulkCopy(cn))
{
copy.ColumnMappings.Add("ID","ID");
copy.ColumnMappings.Add("Value","Value");
copy.DestinationTableName="MYTABLE";
copy.WriteToServer(dtTemp);
}
}
The French/european language characters are not stored properly in SQL server data base.
It works fine when i do a normal insert query. insert into MYTABLE values(1 , 'Accented chars- Les caract?res accentu?s fran?ais')
Please let me know why it does not work with SQL Bulk copy class. Any settings need to be changed or C# code needs to be modified to store the non-English characters properly.
Thanks
Ashok
I am inserting European language text into nvarchar column in SQL server 2008. The accented characters are not stored properly in the SQL DB.
string strData ="Accented chars- Les caract?res accentu?s fran?ais ";
DataTable dtTemp =newDataTable();
dtTemp.Columns.Add("ID",typeof(string));
dtTemp.Columns.Add("Value",typeof(string));
DataRow dr = dtTemp.NewRow();
dr["ID"]="100";
dr["Value"]= strData;
dtTemp.Rows.Add(dr);
strSQLCon =GetSQLConnectionString();
using(SqlConnection cn =newSqlConnection(strSQLCon))
{
cn.Open();
using(SqlBulkCopy copy =newSqlBulkCopy(cn))
{
copy.ColumnMappings.Add("ID","ID");
copy.ColumnMappings.Add("Value","Value");
copy.DestinationTableName="MYTABLE";
copy.WriteToServer(dtTemp);
}
}
The French/european language characters are not stored properly in SQL server data base.
It works fine when i do a normal insert query. insert into MYTABLE values(1 , 'Accented chars- Les caract?res accentu?s fran?ais')
Please let me know why it does not work with SQL Bulk copy class. Any settings need to be changed or C# code needs to be modified to store the non-English characters properly.
Thanks
Ashok