views:

40

answers:

1

I have an old classic ASP application that stores information in a SQL Server 2008 database. I need to retrieve the information in a new .NET application but I am having some encoding issues.

When I look in SQL Management Studio or at the data retrieved in .NET text strings looks weird when it contain Danish characters, e.g “Øvrige” when it should have been “Øvrige”.

The ASP application uses MDAC 2.8 and the native driver with a connection string like:

Provider=SQLNCLI;DataTypeCompatibility=80;Server=.\SQLEXPRESS,1433;Database=MyDB;UID=MyUser;PWD=MyPwd

The database has a Danish_Norwegian_CI_AS collation but that does not seem to have any impact.

I must admit that I have forgotten most of my ASP skills so it may be pretty obvious.

It looks like the ASP application adds some extra encoding or something. Why does it do that?

How can I retrieve and update the information from the database in .NET?

A: 

The following line in the ASP files solves the issue and makes the it store the data correct and redisplay the new data correct:

<% @CodePage = 65001 %>

Now I just need to convert the entire database to solve the issue...

HakonB
This works because you're setting it to use the UTF-8 encoding. (you may know this already, but adding the comment for the sake of others)
mpeterson
You are absolutely right and I should have made that clear.
HakonB