Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 297355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:37:55+00:00 2026-05-12T06:37:55+00:00

I am trying to save unicode data (greek) in oracle database (10 g). I

  • 0

I am trying to save unicode data (greek) in oracle database (10 g). I have created a simple table:

alt text

I understand that NVARCHAR2 always uses UTF-16 encoding so it must be fine for all (human) languages.

Then I am trying to insert a string in database. I have hardcoded the string (“How are you?” in Greek) in code. Then I try to get it back from database and show it.

class Program
{
    static string connectionString = "<my connection string>";

    static void Main (string[] args) {
        string textBefore = "Τι κάνεις;";

        DeleteAll ();
        SaveToDatabase (textBefore);
        string textAfter = GetFromDatabase ();

        string beforeData = String.Format ("Before: {0}, ({1})", textBefore, ToHex (textBefore));
        string afterData = String.Format ("After: {0}, ({1})", textAfter, ToHex (textAfter));

        Console.WriteLine (beforeData);
        Console.WriteLine (afterData);

        MessageBox.Show (beforeData);
        MessageBox.Show (afterData);

        Console.ReadLine ();
    }

    static void DeleteAll () {
        using (var oraConnection = new OracleConnection (connectionString)) {
            oraConnection.Open ();
            var command = oraConnection.CreateCommand ();

            command.CommandText = "delete from UNICODEDATA";
            command.ExecuteNonQuery ();
        }            
    }

    static void SaveToDatabase (string stringToSave) {
        using (var oraConnection = new OracleConnection (connectionString)) {
            oraConnection.Open ();
            var command = oraConnection.CreateCommand ();

            command.CommandText = "INSERT into UNICODEDATA (ID, UNICODESTRING) Values (11, :UnicodeString)";
            command.Parameters.Add (":UnicodeString", stringToSave);
            command.ExecuteNonQuery ();
        }
    }

    static string GetFromDatabase () {
        using (var oraConnection = new OracleConnection (connectionString)) {
            oraConnection.Open ();

            var command = oraConnection.CreateCommand ();
            command.CommandText = "Select * from UNICODEDATA";
            var erpReader = command.ExecuteReader ();

            string s = String.Empty;
            while (erpReader.Read ()) {
                string text = erpReader.GetString (1);
                s += text + ", ";
            }

            return s;
        }
    }

    static string ToHex (string input) {
        string bytes = String.Empty;
        foreach (var c in input)
            bytes += ((int)c).ToString ("X4") + " ";

        return bytes;
    }
}

Here are different outputs:

Text before sending to database in a message box:
alt text

Text after getting from database in a message box:
alt text

Console Output:
alt text

Please can you suggest what I might be doing wrong here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T06:37:56+00:00Added an answer on May 12, 2026 at 6:37 am

    I can see five potential areas for problems:

    1. How are you actually getting the text into your .NET application? If it’s hardcoded in a string literal, are you sure that the compiler is assuming the right encoding for your source file?

    2. There could be a problem in how you’re sending it to the database.

    3. There could be a problem with how it’s being stored in the database.

    4. There could be a problem with how you’re fetching it in the database.

    5. There could be a problem with how you’re displaying it again afterwards.

    Now areas 2-4 sound like they’re less likely to be an issue than 1 and 5. How are you displaying the text afterwards? Are you actually fetching it out of the database in .NET, or are you using Toad or something similar to try to see it?

    If you’re writing it out again from .NET, I suggest you skip the database entirely – if you just display the string itself, what do you see?

    I have an article you might find useful on debugging Unicode problems. In particular, concentrate on every place where the encoding could be going wrong, and make sure that whenever you “display” a string you dump out the exact Unicode characters (as integers) so you can check those rather than just whatever your current font wants to display.

    EDIT: Okay, so the database is involved somewhere in the problem.

    I strongly suggest that you remove anything like ASP and HTML out of the equation. Write a simple console app that does nothing but insert the string and fetch it again. Make it dump the individual Unicode characters (as integers) before and after. Then try to see what’s in the database (e.g. using Toad). I don’t know the Oracle functions to convert strings into sequences of individual Unicode characters and then convert those characters into integers, but that would quite possibly be the next thing I’d try.

    EDIT: Two more suggestions (good to see the console app, btw).

    1. Specify the data type for the parameter, instead of just giving it an object. For instance:

      command.Parameters.Add (":UnicodeString",
                              OracleType.NVarChar).Value = stringToSave;
      
    2. Consider using Oracle’s own driver instead of the one built into .NET. You may wish to do this anyway, as it’s generally reckoned to be faster and more reliable, I believe.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to save data to a database on a button push, but
I'm trying to save some XML-Data in my UserSettings (Properties.Settings.Default.UserSettings) in a .NET Winforms
I'm trying to save a PDF file to SQL Server and I already have
Trying to debug an issue with saving multicharacter data to the database, I narrowed
I am trying to save a modelform that represents a bank account but I
I have a simple Invoices class with a Number attribute that has to be
I trying to save my plist after a simple detail change. Here's the line
Im trying to save data to sdCard first i tried to saave it privately
i have a big issue with dajax and jquery: i'm trying to save the
I'm still on this view. Now I have a ValidationError while trying to save

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.