#include "fivewin.ch"
#include "adodef.ch"
local oCn, cSql
ADOCONNECT oCn TO MSSQL SERVER <server> USER SA PASSWORD <pw>
USE CUSTOMER SHARED
cSql := FW_AdoCreateTableSQL( "CUSTOMER", CUSTOMER->(DBSTRUCT()), oCn )
MemoEdit( cSql ) // script
#include "fivewin.ch"
#include "xbrowse.ch"
#include "ribbon.ch"
#include "hbcompat.ch"
Static oServer
FUNCTION Main()
LOCAL oDlg, oBtn
LOCAL aBtns := Array( 5 )
LOCAL oBrw, oQry // , oServer
local cValType
D_SetCaseSensitive( .T. )
IF ( oServer := ConnectTo() ) == NIL
msgalert('cannot connect to server')
RETURN NIL
ENDIF
oServer:bDebug = {| cQry | LogFile( "debuf.log", {cQry} ) }
// oQry = oServer:Query( "SELECT * FROM rmty_avl") // where rta_rmty='LOB'" )
// oQry:SetPages( 100 )
// oQry:bOnChangePage = { || oBrw:Refresh(), ChangeTitle( oQry, oDlg ) }
USE CCRACCT SHARED
DEFINE DIALOG oDlg TITLE 'Import from Dbf' ; // "Current Page: " + StrZero( oQry:nCurrentPage, 5 ) + " / " + StrZero( oQry:nMaxPages, 5 )
SIZE 565, 480
@ 10, 10 RBBTN oBtn PROMPT 'Test' SIZE 40, 30 OF oDlg ;
ACTION ImportDbf()
// Uncomment this line for fivewin version < 10.7
// SetDolphin( oBrw, oQry )
ACTIVATE DIALOG oDlg CENTERED
CLOSE CCRACCT
RETURN NIL
*-------------------*
Procedure ImportDbf
local cFile := cGetFile32('select dbf |*.DBF','Load file')
FW_AdoImportFromDBF( oServer, cFile, "CCRACCT" )
return
#include "connto.prg"
#include "setbrw.prg"
nageswaragunupudi wrote:FWH itself is a good tool.
Buitin function FW_AdoCreateTableSQL( cTable, aCols, oCn, lAddAutoInc ) returns SQL script to create table.
Usage:
- Code: Select all Expand view
#include "fivewin.ch"
#include "adodef.ch"
local oCn, cSql
ADOCONNECT oCn TO MSSQL SERVER <server> USER SA PASSWORD <pw>
USE CUSTOMER SHARED
cSql := FW_AdoCreateTableSQL( "CUSTOMER", CUSTOMER->(DBSTRUCT()), oCn )
MemoEdit( cSql ) // script
Actually, using FWH, we can even do more.
Using FWAdoCreateTable( cTable, aCols, oCn, lAddAutoInc ), we can actually create a table on the SQL Server with the same structure as the DBF.
We can do more:
Using FW_AdoImportFromDBF( oCn, cDbf, cAdoTable, cColPrefix, nMultiRowSize, aFields ) we can import a DBF to Sql server.
Usage:
FW_AdoImportFromDBF( oCn, "c:\fwh\samples\customer.dbf", "CUSTOMER" )
ADOCONNECT oCn TO MYSQL SERVER localhost DATABASE easyfo USER root PASSWORD nimda
nageswaragunupudi wrote:Mr Dutch
1) Please request DBFCDX. We are using DBFCDX by default. This should solve your DBF Open problem.
2) For this and any FW_Ado* functions to work properly, we need to open ADO connection, preferably using FW_OpenADOConnection( cStr ) function. These ADO functions recognize ADO connection object only and can not recognize oServer object used by TDolphin/TMySql
We tested FW_AdoImportDBF function with Access, MSSql, MySql, Oracle and SQLite. We could export all DBFs in the \fwh\samples folder successfully, including image data etc.
If you do not want to use ADO, probably Mr Daniel might have provided some functionality to export DBF in the dolphin libs.
ADOCONNECT oCn TO MYSQL SERVER localhost DATABASE easyfo USER root PASSWORD nimda
.OR.
cStr := "Driver={MySQL ODBC 3.51 Driver};Server=localhost;" + ;
"Database=easyfo;User=root;Password=nimda;Option=3;"
oCn := FW_OpenAdoConnection( cStr )
nageswaragunupudi wrote:Mr Dutch
1) Please request DBFCDX. We are using DBFCDX by default. This should solve your DBF Open problem.
2) For this and any FW_Ado* functions to work properly, we need to open ADO connection, preferably using FW_OpenADOConnection( cStr ) function. These ADO functions recognize ADO connection object only and can not recognize oServer object used by TDolphin/TMySql
We tested FW_AdoImportDBF function with Access, MSSql, MySql, Oracle and SQLite. We could export all DBFs in the \fwh\samples folder successfully, including image data etc.
If you do not want to use ADO, probably Mr Daniel might have provided some functionality to export DBF in the dolphin libs.
? oCn:Properties( "DBMS Name" ):Value
? oCn:Properties( "Extended Properties" ):Value
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 51 guests