S
Stefano Soratroi
Hi all,
I have the following problem: I have a SQL Server 2000
database with a table containing a column of type nvarchar
(255). In this column the data can contain unicode
characters other than latin1, (ex: greek, korean and so
on). I have written a small .net console application for
testing and in the db field I have written the greek
chars "alfa" "beta" and "gamma" with SQL Server
Enterprise Manager. When I query the table with SQL Query
Analizer it shows me the correct characters, but when I
query the table with my console app, the
charachters "alfa" and "beta" are correct but the "gamma"
charachter is shown as a ?. So I've written a vbs script
that queries the db and the result is that the characters
are all correct, so I suspect it is somewthing wrong or
missing in the .net app. My code is shown below:
using System;
using System.Data;
using System.Data.SqlClient;
using System.Text;
namespace ConsoleApplication1
{
class Class1
{
private const string connstr
= "server=myserver; database=mydb; uid=usr; pwd=pwd";
[STAThread]
static void Main(string[] args)
{
SqlConnection cnn = new
SqlConnection(connstr);
cnn.Open();
string sql = "SELECT nome from
tab";
SqlDataAdapter ad = new
SqlDataAdapter(sql,cnn);
DataSet ds = new DataSet();
ad.Fill(ds);
foreach(DataRow r in ds.Tables
[0].Rows)
Console.WriteLine(r
["nome"].ToString());
cnn.Close();
}
}
}
Any help would be appreciated.
Thanks.
Stefano
I have the following problem: I have a SQL Server 2000
database with a table containing a column of type nvarchar
(255). In this column the data can contain unicode
characters other than latin1, (ex: greek, korean and so
on). I have written a small .net console application for
testing and in the db field I have written the greek
chars "alfa" "beta" and "gamma" with SQL Server
Enterprise Manager. When I query the table with SQL Query
Analizer it shows me the correct characters, but when I
query the table with my console app, the
charachters "alfa" and "beta" are correct but the "gamma"
charachter is shown as a ?. So I've written a vbs script
that queries the db and the result is that the characters
are all correct, so I suspect it is somewthing wrong or
missing in the .net app. My code is shown below:
using System;
using System.Data;
using System.Data.SqlClient;
using System.Text;
namespace ConsoleApplication1
{
class Class1
{
private const string connstr
= "server=myserver; database=mydb; uid=usr; pwd=pwd";
[STAThread]
static void Main(string[] args)
{
SqlConnection cnn = new
SqlConnection(connstr);
cnn.Open();
string sql = "SELECT nome from
tab";
SqlDataAdapter ad = new
SqlDataAdapter(sql,cnn);
DataSet ds = new DataSet();
ad.Fill(ds);
foreach(DataRow r in ds.Tables
[0].Rows)
Console.WriteLine(r
["nome"].ToString());
cnn.Close();
}
}
}
Any help would be appreciated.
Thanks.
Stefano