Solved

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

Posted on 2008-10-06
4
228 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 25

Assisted Solution

by:Luis Pérez
Luis Pérez earned 500 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

733 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