Excel OLEDB reading Chinese characters problem


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Excel OLEDB reading Chinese characters problem

Hybrid View

  1. #1
    Join Date
    Jun 2006
    Posts
    10

    Excel OLEDB reading Chinese characters problem

    Hi All

    I have an excel sheet with Chinese characters in them.

    I'm using the OLEBE 4.0 Jet Driver in C# Microsoft Visual Studio 2005 to read from the Excel sheet and then enter into mySQL database.

    The problem isn't with mysql but with C# reading the chinese characters from Excel.

    Right now, All I get with chinese characters is question marks "?????????"

    MY OLEDB driver should be able to support multi-language but it doesn't seem to be working.

    Can anyone help?

    Code:
     String sConnectionString = 
                "Provider=Microsoft.Jet.OLEDB.4.0;" +
                @"Data Source=C:\language.xls;" + 
                "Extended Properties=Excel 8.0;"; 
    
                OleDbConnection objConn = new OleDbConnection(sConnectionString);
    
                objConn.Open();
    
                OleDbCommand objCmdSelect = new OleDbCommand("SELECT * FROM [Sheet1$]", objConn);
                OleDbDataReader reader = objCmdSelect.ExecuteReader();
    
    
                //---
                String myConnectionString = "server=192.168.168.6;uid=xxxx;pwd=xxxxx;database=xxxxxxx_db;";
                MySqlConnection myConnection = new MySqlConnection(myConnectionString);
                 
     while (reader.Read())
                 {
    
    *this is where I generate my sql query
    }

  2. #2
    Join Date
    Nov 2004
    Location
    Huddinge, Sweden
    Posts
    283
    I think you need to begin by making sure the question marks aren't just a an artifact of how you're displaying them. I've seen many instances where the debugger used a typeface which didn't include extended characters such as Chinese, and the only thing that is displayed are question marks.

    Rune
    If you hit a brick wall, you didn't jump high enough!

  3. #3
    Join Date
    Jun 2006
    Posts
    10

    Talking My Problem Solved!!

    Thank you for your reply Rune, you were the only one.

    After working on this problem for almost the whole day yesterday, and with another person, I found my problem.

    The only reason I want to post again here is so that people won't have to waste hours like I did.

    Firstly, of course you have my to make sure that your tables AND fields are set to UTF-8 generial_ci. All the basics of course.

    Whether you are using C#.Net or VB.Net, use the mysqlCommand >> Parameters Add Object to generate your queries.

    I actually did ALL of the above and more. But the smallest thing I forgot was this :

    Database=Test1;Data Source=pqc96;User Id=root;Password=password;CHARSET=utf8;

    Make sure that CHARSET=utf8 IS INCLUDED IN THE CONNECTION STRING, whether in VB or C#.

    Apparently, if you don't have the in there, no matter what your tables or your OS is set to, it will still input the stupid question marks ????????

    ciao

Similar Threads

  1. Replies: 8
    Last Post: 01-09-2003, 10:42 PM
  2. sudden problem Generating Excel Spreadsheet
    By Nat Grauman in forum ASP.NET
    Replies: 2
    Last Post: 09-27-2002, 05:43 PM
  3. Replies: 0
    Last Post: 12-13-2001, 01:06 PM
  4. Problem using interop to call Excel
    By Marc Mertens in forum .NET
    Replies: 0
    Last Post: 10-04-2001, 05:10 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center