Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Connect to OLEDB provider using ODBC
Message
 
 
À
17/02/2012 14:02:11
Joel Leach
Memorial Business Systems, Inc.
Tennessie, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Client/serveur
Versions des environnements
Visual FoxPro:
VFP 9 SP2
Divers
Thread ID:
01535618
Message ID:
01535685
Vues:
70
In my case the driver is somehow corrupted. I have to re-install it but I don't know from where. In other words, when I try to edit it using ODBC 32 version of the program, I got errors.

Are you able to open and check this driver OK? What is your version of OS and Office?

>>>You need 64 bit drivers.
>>>
>>I do have them, but the question is - will it work from VFP which is 32 bit application?
>
>I believe Office x64 will install both 32-bit and 64-bit drivers, but VFP can only use the 32-bit drivers. This is ok because the drivers work directly with the files. They are not automating Office.
>
>To resolve my issue, I added code to AppendXLSX.prg for using ADO to access the OLEDB driver when the first row contains data rather than column headings. Here is the new code:
>
>	TRY
>		SELECT (m.tvWorkarea)
>		
>        **** New Code Start ****
>	*JAL* Excel ODBC driver has a bug that assumes first row always contains column names
>	*JAL* See http://support.microsoft.com/kb/288343
>	*JAL* If first row contains data, you have to use OLEDB driver and ADO to read data
>	If m.lcHeaderRow = "No"
>		Local loConn as ADODB.Connection, loRS as ADODB.Recordset, loCursor as CursorAdapter
>		
>		loConn = CreateObject("ADODB.Connection")
>		loConn.ConnectionString = [Provider=Microsoft.ACE.OLEDB.12.0;Data Source="] + m.tcXLSFile + [";Extended Properties="Excel 12.0;HDR=] + m.lcHeaderRow + [;";]
>		loConn.Open()
>		If loConn.State = 1	&& connection open
>			loRS = CreateObject("ADODB.Recordset")
>			loRS.ActiveConnection = loConn
>			loCursor = CreateObject("CursorAdapter")
>			loCursor.Alias = m.lcSQLAlias
>			loCursor.DataSourceType = "ADO"
>			loCursor.DataSource = loRS
>	 		loCursor.SelectCmd = "SELECT " + m.tcExcelFieldList + " FROM [" + m.tcSheet + "] Where " + m.tcExcelWhereExpr
>			If !loCursor.CursorFill()
>				AError(laErr)
>				ERROR m.laErr[2]
>			EndIf 
>		EndIf 
>	Else 
>            * Existing code to open ODBC connection ...
>        EndIf
>        **** New Code End ****
>
>	IF USED(m.lcSQLAlias)
>         ...
>
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform