المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Import Data from CSV into Datatable



C# Programming
06-02-2009, 06:31 PM
"Provider=Microsoft.Jet.OLEDB.4.0;"
+ "Data Source=\"" + dir + "\\\";"
+ "Extended Properties=\"text;HDR=No;FMT=Delimited\"";

I'm using the above connection, together with a SELECT * FROM file statement, to pull in data from a comma-delimited text file, where dir is the directory where the file is located and file is the name of the csv file.

This works well for files that contain English characters only, but for any file that uses non-English (ASCII) characters, the expression fails.

I have written the csv file using a StreamWriter with Encoding=UTF8 so the characters display fine when viewed in Notepad or Excel, but when pulled into the DataTable, the value in the table is blank. Is there some Extended Property that can be used to permit East Asian characters, say, to be displayed properly? Thanks.