Display arabic names in ASP.Net from database

663 views Asked by At

I have the following query in ASP.Net page:

SELECT 'محاولة'

This query is printing a hard coded Arabic word. I am saving this record in a DataTable and then printing on page in GridView (by passing that DataTable to GridView) but this Arabic word is being printed as square boxes.

How to print this word properly on ASP.Net page? I tried using following but it didn't work.

SELECT N'محاولة'

EDIT

Here's my code.

DataTable dt = new DataTable();

string sql = "SELECT 'محاولة'";

command.Connection = con;
command.CommandType = CommandType.Text;
command.CommandText = sql;
reader = command.ExecuteReader();
dt.Load(reader);

And then I am passing this "dt" to gridview control.

GridView1.DataSource = dt;
GridView1.DataBind();

Grid view is printing that Arabic word as square boxes (screenshot below).

enter image description here

1

There are 1 answers

0
user3127648 On

Let assume your table structure is as fallow.

Create table Arabic(
id int primary key identity,
Title narchar(100),
);

Now lets add some demo data.

Insert into Arabic values (N'محاوله');

After adding data correctly there you won't have any problem with loading it asp.net page.