Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Connect to OLEDB provider using ODBC
Message
De
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:
01535683
Vues:
133
This message has been marked as the solution to the initial question of the thread.
>>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)
         ...
Joel Leach
Microsoft Certified Professional
Blog: http://www.joelleach.net
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform