Question

I am using ADODB with VB6 to select data from Excel. The "Book_Title" column in Excel contains extended ASCII characters (Abreve-Ă).

But when using the following code, I only get "A" instead of Abreve.

sConn = "DRIVER=Microsoft Excel Driver (*.xls);" & "DBQ=D:\sheik\metadata.xls"
rs.Open "SELECT [Book_Title], [Author_Title] FROM [Sheet1$], sConn
Was it helpful?

Solution

The problem here is that the Excel driver is converting the strings to ANSI symbols, for some reason. Some "clever" code is converting the Ă character (258) to A (65).

If you have the JET drivers with the ISAM Excel driver installed, then the following connection string will use them:

sConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\sheik\metadata.xls;Extended Properties=""Excel 8.0;"""

You will now get back the unconverted strings. However, you probably will not be able to see them correctly in any of the built-in VB controls, or the IDE, for that matter, because it is unlikely that this character exists in your current code page.

But you can confirm that the first character is correct by using the AscW() function to look at the characters in the string, obtained with Mid$().

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top