-
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
}
-
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!
-
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
-
Replies: 8
Last Post: 01-09-2003, 09:42 PM
-
By Nat Grauman in forum ASP.NET
Replies: 2
Last Post: 09-27-2002, 04:43 PM
-
Replies: 0
Last Post: 12-13-2001, 12:06 PM
-
By Marc Mertens in forum .NET
Replies: 0
Last Post: 10-04-2001, 04: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
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks