?
Solved

How do I save and read umlaut characters with DetailsView in Visual Studio?

Posted on 2008-10-06
4
Medium Priority
?
242 Views
Last Modified: 2013-11-26
I'm fairly new to developing in Visual Studio and have run into a problem using DetailsView writing text to SQL Server 2005.

When editing text and saving, characters like ö (o with umlaut) are changed. The character ö becomes ö in the database and when read back into DetailsView.

If I use SQL Server Management Studio to write the character into the database field it is not changed, i.e. it is correct also when read into the DetailsView control. My problem only occurs when saving from the DetailsView control.

I'm sure there's a simple solution to this but I'm stuck, so any help would be greatly appreciated. Thanks!
0
Comment
Question by:MikaelNystrom
  • 2
  • 2
4 Comments
 
LVL 25

Assisted Solution

by:Luis Pérez
Luis Pérez earned 2000 total points
ID: 22648027
Mmmm... I guess that the problem is about the encoding that you are using for you web site. Check the globalization setting in your web.config; it's located inside the system.web element. Check that looks like this (or change if not):

<configuration>
    <system.web>
        <globalization requestEncoding="utf-8" responseEncoding="utf-8" culture="en-US" uiCulture="en-US"/>

Of course, replace "en-US" with your correct culture if you're not located in United States.

Then, try again to save the data to your database.

Hope that helps.
0
 

Author Comment

by:MikaelNystrom
ID: 22648154
Thanks for the suggestion. I added:
<globalization requestEncoding="utf-8" responseEncoding="utf-8" culture="sv-SE" uiCulture="sv-SE"/>

Sorry to say, it didn't help...
0
 
LVL 25

Expert Comment

by:Luis Pérez
ID: 22648313
Can you post the source code of the page that contains the DetailsView control? Not the source code page from Visual Studio, but the source code of the page once it's rendered to internet browser (in IE it's obtained by going to View -> Source code menu option).
0
 

Accepted Solution

by:
MikaelNystrom earned 0 total points
ID: 22648434
I got it to work! Turns out that to save utf-8 in SQL Server I have to use nvarchar (I was using nchar).

Many thanks for your suggestion. I actually didn't have the globalization setting in web.config, so that was a useful thing to add anyway.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses
Course of the Month15 days, 19 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question