but ADO is not "on-Board" in Windows.
// DBase III
c := "c:\fwh\samples\states.dbf"
oCn := FW_OpenAdoConnection( cFilePath( c ) )
oRs := FW_OpenRecordSet( oCn, cFileNoExt( c ) )
XBROWSER oRs
oRs:Close()
oCn:Close()
// MSAccess (*.mdb only)
oCn := FW_OpenAdoConnection( "c:\fwh\samples\xbrtest.mdb" )
oRs := FW_OpenRecordSet( oCn, "customer" )
XBROWSER oRs
oRs:Close()
oCn:Close()
FW_OpenADOExcelSheet( cFile, cSheet, cRange )
// Microsoft SQL Server
// Uses SQLOLEDB driver the comes bundled with Windows
oCn := FW_MSSQLDB() // FWH Cloud server
oRs := FW_OpenRecordset( oCn, "customer" )
XBROWSER oRs
oRs:Close()
oCn:Close()
STATIC FUNCTION ADOOPENCONNECT( cDB, cServer, cPort, cEngine, cUser, cPass, oCn )
LOCAL oCatalog
oCn:ConnectionTimeOut := 60 //26.5.15 28800 //24.5.15 added by lucas de beltran
DO CASE
CASE cEngine = "DBASE"
oCn:Open( "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + cDB + ;
";Extended Properties=dBASE IV;User ID=" + cUser + ";Password=" + cPass + ";" )
CASE cEngine = "FOXPRO"
oCn:Open( "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + cDB + ;
";Extended Properties=Foxpro;User ID=" + cUser + ";Password=" + cPass + ";" )
CASE cEngine = "ACCESS"
IF !FILE( cDB )
oCatalog := ADOCLASSNEW( "ADOX.Catalog" ) //TOleAuto():New( "ADOX.Catalog" )
oCatalog:Create( "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + cDB )
ENDIF
IF EMPTY( cPass )
oCn:Open( "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + cDB )
ELSE
oCn:Open( "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + cDB + ";Jet OLEDB:Database Password=" + ALLTRIM( cPass ) )
ENDIF
CASE cEngine = "ADS"
oCn:Open( "Provider=Advantage OLE DB Provider;User ID=" + cUser + ;
";Password=" + cPass + ";Data Source=" + cDB + ";TableType=ADS_VFP;" + ;
"Advantage Server Type=ADS_LOCAL_SERVER;" )
CASE cEngine == "MYSQL"
IF( cPort == NIL, cPort := "3306", cPort )
oCn:Open( "Driver={mySQL ODBC 5.3 ANSI Driver};" + ;
"server=" + cServer + ;
";Port=" + cPort + ;
";database=" + cDB + ;
";uid=" + cUser + ;
";pwd=" + cPass + ";" )
CASE cEngine == "MARIADB"
t_cEngine := "MYSQL" //ITS THE SAME SHOULD WORK LIKE THIS IN ALL ROUTINES
IF( cPort == NIL, cPort := "3306", cPort )
oCn:Open( "Driver={mySQL ODBC 5.3 ANSI Driver};" + ;
"server=" + cServer + ;
";Port=" + cPort + ;
";db=" + cDB + ;
";uid=" + cUser + ;
";pwd=" + cPass + ";" )
CASE cEngine == "MSSQL"
oCn:Open( "Provider=SQLOLEDB;" + ;
"server=" + cServer + ;
";database=" + cDB + ;
IIF( EMPTY( cUser ), ";Trusted_Connection=yes", ;
";uid=" + cUser + ;
";pwd=" + cPass ) )
CASE cEngine == "ORACLE"
oCn:Open( "Provider=MSDAORA.1;" + ;
"Persist Security Info=False" + ;
IIF( EMPTY( cServer ), ;
"", ";Data source=" + cServer ) + ;
";User ID=" + cUser + ;
";Password=" + cPass )
CASE cEngine == "FIREBIRD"
oCn:Open( "Driver=Firebird/InterBase(r) driver;" + ;
"Persist Security Info=False" + ;
";Uid=" + cUser + ;
";Pwd=" + cPass + ;
";DbName=" + cDB )
CASE cEngine == "SQLITE"
oCn:Open( "Driver={SQLite3 ODBC Driver};" + ;
"Database=" + cDB + ;
";LongNames=0;Timeout=1000;NoTXN=0;SyncPragma=NORMAL;StepAPI=0;" )
CASE cEngine == "POSTGRE"
IF( cPort == NIL, cPort := "5432", cPort )
//PostgreSQL ANSI //ODBC Driver(ANSI)
oCn:Open( "Driver={PostgreSQL ANSI};Server=" + cServer + ";Port=" + cPort + ";" + ;
"Database=" + cDB + ;
";Uid=" + cUser + ";Pwd=" + cPass + ";" )
CASE cEngine == "INFORMIX"
oCn:Open( "Dsn='';Driver={INFORMIX 3.30 32 BIT};" + ;
"Host=" + "" + ";Server=" + cServer + ";" + ;
"Service=" + "" + ";Protocol=olsoctcp;" + ;
"Database=" + cDB + ";Uid=" + cUser + ";" + ;
"Pwd=" + cPass + ";" )
CASE cEngine == "ANYWHERE"
IF( cPort == NIL, cPort := "2638", cPort )
oCn:Open( "Driver={SQL Anywhere 12};" + ;
"Host=" + cServer + ";Server=" + cServer + ";port=" + cPort + ";" + ;
"db=" + cDB + ;
IIF( EMPTY( cUser ), ";Trusted_Connection=yes", ;
";uid=" + cUser + ;
";pwd=" + cPass ) )
OTHERWISE
MSGALERT( "Connection failed DB engine " + cEngine + " its unknown to ADORDD!" )
ENDCASE
RETURN oCn
can i use these ConnectionString with Fivewin
oCn := FW_OpenAdoConnection( cYourConnectionString, .t. )
FW_OpenAdoConnection( cFWConnectSpec[or]cYourConnectionString, [lShowError],[@oError]) --> oCn
// oCn is NIL if failed
{ cRDBMS, cServer, cDB, cUser, cPassword}
oCn := FW_OpenAdoConnection( { "MYSQL","209.250.245.152","fwh","fwhuser","FiveTech@2022" }, .t. )
oRs := FW_OpenADOExcelSheet ( cFile, cSheet, cRange )
XBROWSER oRs
Error description: (DOS Error -2147352570) WINOLE/1009 No exported method: ISKINDOF
Args:
[ 1] = C TLINKLIST
Stack Calls
===========
Called from: => TOLEAUTO:ISKINDOF( 0 )
Called from: .\source\function\XBROWSER.PRG => XBROWSE( 101 )
Called from: .\DUALGRID.PRG => OPENADOEXCEL( 6126 )
Called from: .\DUALGRID.PRG => VIEWER( 2565 )
Error description: Error BASE/1004 Message not found: TXBROWSE:SALES
Stack Calls
===========
Called from: .\source\function\HARBOUR.PRG => _CLSSETERROR( 247 )
Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:SALES( 11834 )
Called from: xbrxls.prg => MAIN( 28 )
Error description: (DOS Error -2147352570) WINOLE/1009 No exported method: ISKINDOF
oRs := FW_OpenADOExcelSheet( "customer.xlsx" )
XBROWSER oRs SETUP ( oBrw:AutoFit() )
i found c:\fwh\samples\xbrxls.prg
but it crash ...
oRange := GetExcelRange( cBook, [cSheet], [cRange] )
XBROWSER GetExcelRange( cExcelBookNameFullPath )
if ValType( uData ) == "H" .or. ( ValType( uData ) == "O" .and. uData:IsKindOf( "TLINKLIST" ) )
if ValType( uData ) == "H" .or. ( ValType( uData ) == "O" .and. ;
__ObjHasMethod( uData, "ISKINDOF" ) .and. uData:IsKindOf( "TLINKLIST" ) )
strHeader := "HDR=YES;"
oConnect := CreateObject( "ADODB.Connection" )
oConnect:ConnectionString := 'Provider=Microsoft.ACE.OLEDB.12.0;' + ;
'Data Source=' + cFile + ';' + ;
'Extended Properties="Excel 12.0 Xml;' + strHeader + 'IMEX=1' + '";'
bError := ERRORBLOCK( { | oErr | BREAK( oErr ) } )
BEGIN SEQUENCE
oConnect:Open()
RECOVER USING oError
ERRORBLOCK( bError )
MsgStop( "Operation: " + oError:Operation + " - Description: " + oError:Description, "Error ConnectionString" )
RETURN .F.
END SEQUENCE
ERRORBLOCK( bError )
@ 1, 1 XBROWSE oBrw SIZE - 1, - 1 PIXEL OF oDlg ;
RECORDSET objRS ;
HEADERS aHead ;
AUTOCOLS ;
CELL LINES NOBORDER FASTEDIT ;
FONT oFontDefault COLOR BFcolor, BGcolor
objRS := CreateObject( "ADODB.Recordset" )
bError := ERRORBLOCK( { | oErr | BREAK( oErr ) } )
BEGIN SEQUENCE
* objRS:Open( "Select * from [" + strRange + "]", oConnect, adOpenStatic )
objRS:Open( "Select * from [" + strRange + "]", oConnect, adOpenKeyset, adLockOptimistic )
there seems to be NO "Microsoft.ACE.OLEDB.12.0" on Microsoft Windows [Version 10.0.25387.1] (latest Canary Version)
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 28 guests