1
votes

I'm trying to move some old classic ASP website to Azure App Service. The webpages work fine, but show national characters from varchar columns as question marks.

How to reproduce:

  • Create a SQL Server database (on Azure or on other SQL Server) with Cyrillic_General_100_CI_AS collation

  • Create the table with varchar and nvarchar columns:

    create table dbo.Test 
    (
          id int identity (1,1) not null,
          code varchar(255) null,
          name nvarchar(255) null
    )
    
  • Insert some test data:

    insert dbo.Test (code, name) 
    values ('привет-1', N'привет-2')
    
    insert dbo.Test (code, name) 
    values ('привет-3', N'привет-4')
    
  • Ensure that data is selected fine in SSMS:

    select * from dbo.Test:
    
    id  code    name
    1   привет-1    привет-2
    2   привет-3    привет-4
    
  • Create a webpage that displays data:

    id  code    name
    1   ??????-1    привет-2
    2   ??????-3    привет-4
    

So, the nvarchar columns show up fine, but varchar columns do not. Using the following code on the Azure web page doesn't help:

Response.CharSet = "windows-1251"
Response.CodePage = 1251
Session.CodePage = 1251 

On "regular" IIS everything is shown fine - maybe because it has "ASP encoding" setting. Anybody knows how to fix that on Azure?

Thanks in advance

1
Well, then use nvarchar for anything Cyrillic and be done with it ! Cyrillic characters do need the Unicode support that only the nvarchar datatype can provide. So what exactly is the question then?? Just use nvarchar:...marc_s
Marc, on "regular" IIS the same webpage worked fine for years and works fine now, even with varchar. Why it cannot work on Azure? And converting the existing varchar columns to nvarchar on existing (big!) database is not an option - because it requires also mass changes to existing webpages (adding N' to every insert statement etc..)Leo

1 Answers

1
votes

The best solution is to change varchar to nvarchar as marc_s said. If it is not a good solution for you, please try to set Collation as "Cyrillic_General_CI_AS" when creating your Azure SQL Database. Refer to this article for more detailed information.

enter image description here

Here is my result: (just create a mvc controller with view using Entity framework)

enter image description here