CAST is an SQL-Server expression. use SELECT Field FROM...
in delphi: ADOQuery.FieldByName('Field').AsString
you cannot use it with an SQL statement.
when using mixed data types :
Read this from the MSDN (Mixed Data Type Warning):
ADO must guess the data type for each column in an Excel sheet or range. (This is not affected by the formatting of the Excel settings cell.) A serious problem can occur if you have numeric values โโmixed with text values โโin the same column. Both Jet and the ODBC Provider return majority type data, but return NULL (empty) values โโfor the minority data type. If the two types are equally mixed in the column, the provider selects the numeric text.
you need to add IMEX=1
in the Advanced Properties section of the connection string. the constant field will have a TWideStringField.
The connection string should look something like this:
Provider=Microsoft.Jet.OLEDB.4.0;Password="";User ID=Admin;Data Source=C:\MyFile.xls;Mode=Share Deny None;Extended Properties="Excel 8.0;IMEX=1";...
kobik
source share