Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Windows 10 64 bit and Craig Boyd's program for Excel
Message
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Title:
Windows 10 64 bit and Craig Boyd's program for Excel
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 10
Database:
MS SQL Server
Miscellaneous
Thread ID:
01639838
Message ID:
01639838
Views:
351
Hi everybody,

When I ran 32 bit ODBC application I see the following (see the attached picture). When I tried to run Craig Boyd program to load from Excel file (xlsx) I first got prompted about DSN, then I tried to create one and I only saw xls as possible choice, then it gave me an error about reading file.

I have the latest Office2016 64bit (BTW, I tried to find 'About' in Outlook or Excel and didn't find it - where is it) and I have Windows 10 64 bit.

What should I install to make the program work?

Here is some code from it:
TRY
      SELECT (m.tvWorkarea)
      
      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 + [;";]
      =CURSORSETPROP("FetchMemo",.t.,0)

      try
        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.FetchMemo = .t.
         loCursor.SelectCmd = "SELECT " + m.tcExcelFieldList + " FROM [" + m.tcSheet + "] Where " + m.tcExcelWhereExpr
         lnSQL = 0
         If !loCursor.CursorFill()
            lnSQL = - 1
            aerror(laErr)
            *ERROR m.laErr[2]
            oAppObj.write_log('ADODB Connection CursorFill method resulted in error for ' + m.tcXLSFile + ' sheet ' + m.tcSheet + CHR(13) + ;
                              'Error message is: ' + m.laErr[2], PROGRAM(),'E') 
         EndIf 
      ELSE 
         lnSQL = - 1 
         oAppObj.write_log('ADODB Connection can not be opened for ' + m.tcXLSFile + ' sheet ' + m.tcSheet + CHR(13) + ;
                              'Error message is: ' + m.laErr[2], PROGRAM(),'E')
      EndIf       
      CATCH TO loException 
         lnSQL = - 1
         oAppObj.write_log('ADODB Connection can not be opened for ' + m.tcXLSFile + ' sheet ' + m.tcSheet + CHR(13) + ;
                              'Error message is: ' + loException.Message, PROGRAM(),'E')
                       
      endtry
      if m.lnSQL < 0
         lnSQL = sqlstringconnect([Provider=Microsoft.ACE.OLEDB.12.0;Data Source="] + m.tcXLSFile + [";Extended Properties="Excel 8.0;HDR=] + m.lcHeaderRow + [;";])

      *!* Alternate using DSN that comes with Office install (MSDASQL = OLEDB wrapper for ODBC)
      *!*         m.lnSQL = SQLSTRINGCONNECT("Provider=MSDASQL.1;" ;
      *!*            +"Persist Security Info=False;" ;
      *!*            +"DSN=Excel Files;" ;
      *!*            +"DBQ="+FULLPATH(m.tcXLSFile)+";" ;
      *!*            +"DriverId=790;" ;
      *!*            +"MaxBufferSize=2048;" ;
      *!*            +"PageTimeout=5;")

      *!* Try a few other drivers that may be on the user's machine
         if m.lnSQL < 0

            aerror(laErr)

            oAppObj.write_log('Connection with Provider=Microsoft.ACE.OLEDB.12.0 is failing for ' + m.tcXLSFile + ' sheet ' + m.tcSheet + chr(13) + ;
               'Error message is: ' + m.laErr[2], program(),'E')

            lnSQL = sqlstringconnect("Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};" ;
               + "DBQ="+fullpath(m.tcXLSFile)+";")
            
            if m.lnSQL < 0 and upper(alltrim(justext(m.tcXLSFile))) == "XLS" && can we try using the older driver?
               
            aerror(laErr)

            oAppObj.write_log('Connection with Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)} is failing for ' + m.tcXLSFile + ' sheet ' + m.tcSheet + chr(13) + ;
               'Error message is: ' + m.laErr[2], program(),'E')
               if m.lnSQL < 0
                  lnSQL = sqlstringconnect("Driver={Microsoft Excel Driver (*.xls)};" ;
                     + "DBQ="+fullpath(m.tcXLSFile)+";")
                  
               endif
            endif
            if m.lnSQL < 0
               aerror(m.laErr)

               oAppObj.write_log('Connection with old Driver={Microsoft Excel Driver (*.xls)} is failing for ' + m.tcXLSFile + ' sheet ' + m.tcSheet + chr(13) + ;
               'Error message is: ' + m.laErr[1,2], program(),'E')
                error m.laErr[2]
            endif
         endif
      endif
If it's not broken, fix it until it is.


My Blog
Next
Reply
Map
View

Click here to load this message in the networking platform