DBF to SQL script tool

DBF to SQL script tool

Postby cdmmaui » Thu Jun 19, 2014 8:24 pm

Hello,

Can anyone recommend a good tool to create a MS SQL script from DBF structure?

Thank you for your assistance.

Sincerely,
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
User avatar
cdmmaui
 
Posts: 689
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong

Re: DBF to SQL script tool

Postby nageswaragunupudi » Thu Jun 19, 2014 10:39 pm

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  RUN

#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" )
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: DBF to SQL script tool

Postby dutch » Fri Jun 20, 2014 3:46 am

Dear Mr.Rao,

I try FW__AdoImportFromDBF( oServer, cDbfFileName ) but it always show "Can not open" cDbfFileName.
I use FWH1312+xHB1310+TDolphin.

Code: Select all  Expand view  RUN
#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"  
 


Thanks in advance.
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  RUN

#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" )
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: DBF to SQL script tool

Postby nageswaragunupudi » Fri Jun 20, 2014 3:58 am

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.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: DBF to SQL script tool

Postby dutch » Fri Jun 20, 2014 4:08 am

Dear Mr.Rao,

Can I use this OpenConnection()
Code: Select all  Expand view  RUN
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.
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: DBF to SQL script tool

Postby dutch » Fri Jun 20, 2014 4:17 am

Dear Mr.Rao,

I try both code and it's working now.
Code: Select all  Expand view  RUN
   
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.
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: DBF to SQL script tool

Postby cdmmaui » Fri Jun 20, 2014 4:21 am

Thank You Very Much!
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
User avatar
cdmmaui
 
Posts: 689
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong

Re: DBF to SQL script tool

Postby nageswaragunupudi » Fri Jun 20, 2014 5:20 am

Mr Dutch

Glad the functions are working for you now.

FW_OpenAdoConnection( cFullConnectionString ) works. But we need to know whether the target PC is using version 3.51 or 5.1.

I advise using either:
1) ADOCONNECT oCn TO MYSQL SERVER localhost DATABASE easyfo USER root PASSWORD nimda
or
2) oCn := FW_OpenAdoConnection( "MYSQL,localhost,easyfo,root,nimda" ) // fwh's connection spec format.

FWH uses the version avaible on the PC and uses that version to connect.

Same is the case with Access, MSSql, Oracle, etc. Better we let FWH to use the driver/provider available on the customer's PC.

Mr Darrell Ortiz

Hope the information is useful to you.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: DBF to SQL script tool

Postby cdmmaui » Fri Jun 27, 2014 1:40 am

Dear Mr. Rao,

Is there a limit to the number of fields? I am trying to create script for DBF that has 279 fields and I am getting the following error.

I am trying to connect to MS SQL 2008.

Source code is below error.

Application
===========
Path and name: C:\Winapps\cargo\data\cdmsql.exe (32 bits)
Size: 2,546,688 bytes
Compiler version: xHarbour 1.2.3 Intl. (SimpLex) (Build 20130422)
FiveWin Version: FWHX 14.06
Windows version: 6.1, Build 7601 Service Pack 1

Time from start: 0 hours 0 mins 2 secs
Error occurred at: 06/26/2014, 20:34:18
Error description: Error BASE/1132 Bound error: array access
Args:
[ 1] = A { ... }
[ 2] = N 1

Stack Calls
===========
Called from: .\source\function\ADOFUNCS.PRG => FW_ADOCREATETABLESQL( 678 )
Called from: cdmsql.prg => _SQLSCRIPT( 102 )
Called from: cdmsql.prg => (b)MAIN( 54 )
Called from: .\source\classes\MENU.PRG => TMENU:COMMAND( 463 )
Called from: .\source\classes\WINDOW.PRG => TWINDOW:COMMAND( 1050 )
Called from: => TWINDOW:HANDLEEVENT( 0 )
Called from: .\source\classes\WINDOW.PRG => _FWH( 3279 )
Called from: => WINRUN( 0 )
Called from: .\source\classes\WINDOW.PRG => TWINDOW:ACTIVATE( 1003 )
Called from: cdmsql.prg => MAIN( 72 )


// Source code...
//----------------------------------------------------------------------------//
function _SqlScript( oSay, oSay2 )

local lFail := .F. , ;
cSkipped := '' , ;
oCn , ;
cSql , ;
cSqlCon := "" , ;
aCdmDbf := Directory( "*.DBF" ) , ;
nX1 := 0 , ;
cTotSql := "" , ;
cCdmDbf := ""

// Init...
cSqlCon := "Server=0.0.0.0;Database=CDMWINFRT;User Id=xxxxxxxxxx;Password=xxxxxxxxxx;"

// Connect to MS SQL...
oCn := FW_OpenAdoConnection( cSqlCon )

FOR nX1=1 TO LEN( aCdmDbf )
cCdmDbf := aCdmDbf[nX1,1]

oSay:SetText( "Creating SQL Script for " + cCdmDbf + " . . ." )
SysRefresh()

USE (cCdmDbf) SHARED
cSql := FW_AdoCreateTableSQL( cCdmDbf, (cCdmDbf)->(DBSTRUCT()), oCn )
cTotSql += cSql
DbCloseAll()
EXIT
NEXT nX1

MemoEdit( cTotSql ) // script
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
User avatar
cdmmaui
 
Posts: 689
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong

Re: DBF to SQL script tool

Postby cdmmaui » Fri Jun 27, 2014 2:42 am

Dear Mr. Rao,

I found the problem. I did not truncate the .DBF.
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
User avatar
cdmmaui
 
Posts: 689
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong

Re: DBF to SQL script tool

Postby cdmmaui » Fri Jun 27, 2014 4:00 am

Mr. Rao,

I am having a problem with script. The function is return the following SQL script. However, the syntax is not correct for MS SQL, `ID` should be [ID]. I see a function (FW_RDBMSName)is called to determine DBMS type but it does not seem to be working. Can you tell me what I am doing wrong?

CREATE TABLE `air` ( `ID` INT AUTO_INCREMENT PRIMARY KEY, `COMPANY` VARCHAR ( 3 ), `QUOTENO` VARCHAR ( 15 ), `STATION` VARCHAR ( 3 ), `DSTSTAT` VARCHAR ( 3 ), `HSE` VARCHAR ( 1 ), `HOUSE` BIT DEFAULT 0, `FILE` VARCHAR ( 20 ), `SERIAL` VARCHAR ( 10 ), `BOOKNO` VARCHAR ( 20 ), `MODE` VARCHAR ( 1 ), `TRANS` VARCHAR ( 1 ), `MOVE` VARCHAR ( 1 ), `DATE` DATE, `STATUS` VARCHAR ( 1 ), `SHIPID` VARCHAR ( 10 ), `SHIPNAME` VARCHAR ( 50 ), `SHIPADD1` VARCHAR ( 50 ), `SHIPADD2` VARCHAR ( 50 ), `SHIPADD3` VARCHAR ( 50 ), `SHIPCITY` VARCHAR ( 50 ), `SHIPST` VARCHAR ( 5 ), `SHIPSTE` BIT DEFAULT 0, `SHIPZIP` VARCHAR ( 10 ), `SHIPISO` VARCHAR ( 2 ), `SHIPISOP` BIT DEFAULT 0, `REFERENCE` VARCHAR ( 35 ), `SHIPCONT` VARCHAR ( 35 ), `SHIPCONTP` BIT DEFAULT 0, `SHIPPH` VARCHAR ( 20 ), `SHIPPHP` BIT DEFAULT 0, `SHIPFAX` VARCHAR ( 20 ), `SHIPFAXP` BIT DEFAULT 0, `SHIPREP` VARCHAR ( 10 ), `CONSID` VARCHAR ( 10 ), `CONSNAME` VARCHAR ( 50 ), `CONSADD1` VARCHAR ( 50 ), `CONSADD2` VARCHAR ( 50 ), `CONSADD3` VARCHAR ( 50 ), `CONSCITY` VARCHAR ( 50 ), `CONSST` VARCHAR ( 5 ), `CONSSTE` BIT DEFAULT 0, `CONSZIP` VARCHAR ( 10 ), `CONSREF` VARCHAR ( 35 ), `CONSISO` VARCHAR ( 2 ), `CONSISOP` BIT DEFAULT 0, `CONSCONT` VARCHAR ( 35 ), `CONSCONTP` BIT DEFAULT 0, `CONSPH` VARCHAR ( 20 ), `CONSPHP` BIT DEFAULT 0, `CONSFAX` VARCHAR ( 20 ), `CONSFAXP` BIT DEFAULT 0, `CONSREP` VARCHAR ( 10 ), `NOTIID` VARCHAR ( 10 ), `NOTINAME` VARCHAR ( 50 ), `NOTIADD1` VARCHAR ( 50 ), `NOTIADD2` VARCHAR ( 50 ), `NOTIADD3` VARCHAR ( 50 ), `NOTICITY` VARCHAR ( 50 ), `NOTIST` VARCHAR ( 5 ), `NOTISTE` BIT DEFAULT 0, `NOTIZIP` VARCHAR ( 10 ), `NOTIISO` VARCHAR ( 2 ), `NOTIISOP` BIT DEFAULT 0, `NOTICONT` VARCHAR ( 30 ), `NOTICONTP` BIT DEFAULT 0, `NOTIPH` VARCHAR ( 20 ), `NOTIPHP` BIT DEFAULT 0, `NOTIFAX` VARCHAR ( 20 ), `NOTIFAXP` BIT DEFAULT 0, `PICKID` VARCHAR ( 10 ), `PICKNAME` VARCHAR ( 50 ), `PICKADD1` VARCHAR ( 50 ), `PICKADD2` VARCHAR ( 50 ), `PICKADD3` VARCHAR ( 50 ), `PICKCITY` VARCHAR ( 50 ), `PICKST` VARCHAR ( 5 ), `PICKZIP` VARCHAR ( 10 ), `PICKCONT` VARCHAR ( 30 ), `PICKPH` VARCHAR ( 20 ), `PICKFAX` VARCHAR ( 20 ), `DESTID` VARCHAR ( 10 ), `DESTNAME` VARCHAR ( 50 ), `DESTADD1` VARCHAR ( 50 ), `DESTADD2` VARCHAR ( 50 ), `DESTADD3` VARCHAR ( 50 ), `DESTCITY` VARCHAR ( 50 ), `DESTST` VARCHAR ( 5 ), `DESTZIP` VARCHAR ( 10 ), `DESTCONT` VARCHAR ( 30 ), `DESTPH` VARCHAR ( 20 ), `DESTFAX` VARCHAR ( 20 ), `ACCTID` VARCHAR ( 10 ), `ACCT01` VARCHAR ( 50 ), `ACCT02` VARCHAR ( 50 ), `ACCT03` VARCHAR ( 50 ), `ACCT04` VARCHAR ( 50 ), `ACCT05` VARCHAR ( 50 ), `ACCT06` VARCHAR ( 50 ), `ACCT07` VARCHAR ( 50 ), `ACCT08` VARCHAR ( 50 ), `EXREF01` VARCHAR ( 45 ), `EXREF02` VARCHAR ( 45 ), `EXREF03` VARCHAR ( 45 ), `CARRIER` VARCHAR ( 20 ), `CARRIER2` VARCHAR ( 20 ), `CARRIER3` VARCHAR ( 20 ), `CARRIER4` VARCHAR ( 20 ), `MANIFEST` VARCHAR ( 20 ), `SUBMAN` VARCHAR ( 20 ), `PFX` VARCHAR ( 3 ), `PFX02` VARCHAR ( 3 ), `PFX03` VARCHAR ( 3 ), `PFX04` VARCHAR ( 3 ), `MBILL` VARCHAR ( 20 ), `MBILL2` VARCHAR ( 20 ), `MBILL3` VARCHAR ( 20 ), `MBILL4` VARCHAR ( 20 ), `HBILL` VARCHAR ( 20 ), `BOOKING` VARCHAR ( 20 ), `TO01` VARCHAR ( 4 ), `TO02` VARCHAR ( 4 ), `BY02` VARCHAR ( 3 ), `TO03` VARCHAR ( 4 ), `BY03` VARCHAR ( 3 ), `TO04` VARCHAR ( 4 ), `BY04` VARCHAR ( 4 ), `CURRENCY` VARCHAR ( 10 ), `WTVAL` VARCHAR ( 1 ), `OTHER` VARCHAR ( 1 ), `CARVAL` VARCHAR ( 15 ), `CUSVAL` VARCHAR ( 15 ), `INSVAL` VARCHAR ( 15 ), `AIRMIN` VARCHAR ( 1 ), `PICKDATE` DATE, `PICKTIME` VARCHAR ( 10 ), `DELVDATE` DATE, `DELVTIME` VARCHAR ( 10 ), `FLT01` VARCHAR ( 10 ), `DTE01` DATE, `TME01` VARCHAR ( 5 ), `FLT02` VARCHAR ( 10 ), `DTE02` DATE, `TME02` VARCHAR ( 5 ), `FLT03` VARCHAR ( 10 ), `DTE03` DATE, `TME03` VARCHAR ( 5 ), `FLT04` VARCHAR ( 10 ), `DTE04` DATE, `TME04` VARCHAR ( 5 ), `PRECARRID` VARCHAR ( 10 ), `PRECARR` VARCHAR ( 50 ), `PRCODE` VARCHAR ( 3 ), `PLACEREC` VARCHAR ( 50 ), `ORCODE` VARCHAR ( 3 ), `ORIGIN` VARCHAR ( 50 ), `CONSOL` VARCHAR ( 3 ), `POL` VARCHAR ( 3 ), `POL02` VARCHAR ( 3 ), `POL03` VARCHAR ( 3 ), `POL04` VARCHAR ( 3 ), `PORTLOAD` VARCHAR ( 50 ), `POUL` VARCHAR ( 3 ), `POUL02` VARCHAR ( 3 ), `POUL03` VARCHAR ( 3 ), `POUL04` VARCHAR ( 3 ), `PORTDISC` VARCHAR ( 50 ), `PDCODE` VARCHAR ( 3 ), `PLACEDEL` VARCHAR ( 50 ), `ULCODE` VARCHAR ( 3 ), `ULTIMATE` VARCHAR ( 50 ), `SERVICE` VARCHAR ( 20 ), `PRIORITY` VARCHAR ( 1 ), `DEPART` DATE, `ETA` DATE, `ETATIME` VARCHAR ( 8 ), `ETA02` DATE, `ETATIME2` VARCHAR ( 8 ), `ETA03` DATE, `ETATIME3` VARCHAR ( 8 ), `ETA04` DATE, `ETATIME4` VARCHAR ( 8 ), `HSECAR` VARCHAR ( 10 ), `HANDLE01` VARCHAR ( 105 ), `HANDLE02` VARCHAR ( 105 ), `HANDLE03` VARCHAR ( 105 ), `DELV01` VARCHAR ( 75 ), `DELV02` VARCHAR ( 75 ), `DELV03` VARCHAR ( 75 ), `RATEID` VARCHAR ( 15 ), `WTPPD` DECIMAL( 15, 2 ), `WTCOL` DECIMAL( 15, 2 ), `VCPPD` DECIMAL( 15, 2 ), `VCCOL` DECIMAL( 15, 2 ), `TXPPD` DECIMAL( 15, 2 ), `TXCOL` DECIMAL( 15, 2 ), `DAPPD` DECIMAL( 15, 2 ), `DACOL` DECIMAL( 15, 2 ), `DCPPD` DECIMAL( 15, 2 ), `DCCOL` DECIMAL( 15, 2 ), `TOTPPD` DECIMAL( 15, 2 ), `TOTCOL` DECIMAL( 15, 2 ), `WBLINE01` VARCHAR ( 125 ), `WBLINE02` VARCHAR ( 125 ), `WBLINE03` VARCHAR ( 125 ), `WBLINE04` VARCHAR ( 125 ), `ISSDATE` DATE, `ISSPLACE` VARCHAR ( 30 ), `WTCODE` VARCHAR ( 1 ), `OFFICIAL` VARCHAR ( 15 ), `INVCNT` BIGINT, `INCH` VARCHAR ( 1 ), `DIMFACT` BIGINT, `DIMWT` BIGINT, `ZONEF` TINYINT, `ZONET` TINYINT, `ZF01` VARCHAR ( 1 ), `ZF02` VARCHAR ( 1 ), `ZF03` VARCHAR ( 1 ), `ZF04` VARCHAR ( 1 ), `ZT01` VARCHAR ( 1 ), `ZT02` VARCHAR ( 1 ), `ZT03` VARCHAR ( 1 ), `ZT04` VARCHAR ( 1 ), `AIRCOMM` BIT DEFAULT 0, `AIRPERCENT` DECIMAL( 11, 2 ), `BILLABLE` BIT DEFAULT 0, `READY` VARCHAR ( 5 ), `CLOSE` VARCHAR ( 5 ), `TRANSMIT` BIT DEFAULT 0, `AWBM` VARCHAR ( 30 ), `ADDBY` VARCHAR ( 20 ), `ADDDATE` DATE, `LASTUSER` VARCHAR ( 20 ), `LASTDATE` DATE, `LASTTIME` VARCHAR ( 8 ), `SITA` BIT DEFAULT 0, `SITAFLAG` VARCHAR ( 1 ), `SITADATE` DATE, `SITATIME` VARCHAR ( 4 ), `SITACODE` VARCHAR ( 3 ), `SITALDATE` DATE, `SITALTIME` VARCHAR ( 4 ), `CLOSED` BIT DEFAULT 0, `CLOSEDATE` DATE, `CLOSETIME` VARCHAR ( 5 ), `CLOSEUSER` VARCHAR ( 15 ), `CUSTID` VARCHAR ( 10 ), `CUSTNAME` VARCHAR ( 45 ), `CUSTREP` VARCHAR ( 10 ), `COONAME` VARCHAR ( 75 ), `COOCOUNTRY` VARCHAR ( 75 ), `COOBODY` TEXT, `DOCKBODY` TEXT, `REP` VARCHAR ( 10 ), `ACTUAL` DATE, `INVOICED` BIT DEFAULT 0, `INVOICE` VARCHAR ( 20 ), `INVDATE` DATE, `INVUSER` VARCHAR ( 15 ), `TRADELANE` VARCHAR ( 10 ), `CUSTOM01` VARCHAR ( 20 ), `CUSTOM02` VARCHAR ( 20 ), `CUSTOM03` VARCHAR ( 20 ), `CUSTOM04` VARCHAR ( 20 ), `CUSTOM05` VARCHAR ( 20 ), `BLDIVER` BIT DEFAULT 0, `FWBDATE` DATE, `FWBTIME` VARCHAR ( 8 ), `FWBUSER` VARCHAR ( 15 ), `FWBNO` VARCHAR ( 10 ), `FHLDATE` DATE, `FHLTIME` VARCHAR ( 8 ), `FHLUSER` VARCHAR ( 15 ), `FHLNO` VARCHAR ( 10 ), `ESTREVENUE` DECIMAL( 13, 2 ), `UNKNOWN` VARCHAR ( 75 ), `ITEM1` VARCHAR ( 75 ), `ITEM2` VARCHAR ( 75 ), `ITEM3` VARCHAR ( 75 ) )
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
User avatar
cdmmaui
 
Posts: 689
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong

Re: DBF to SQL script tool

Postby nageswaragunupudi » Fri Jun 27, 2014 4:27 am

Mr Ortiz

The syntax of the SQL generated corresponds to MYSQL. Obviously, the FW_RDBSName( oCn ) function is recognizing the connection as MYSQL connection but not MSSQL connection.

During development, I tested all the functions with Access, MySql, SqlExpress ( MsSql ), Oracle Express and SQLite3. Still something seems to be going wrong.

Please help me to locate the problem by doing small tests and providing the results.
After you open the connection with your connection string, please execute:
Code: Select all  Expand view  RUN
? oCn:Properties( "DBMS Name" ):Value
? oCn:Properties( "Extended Properties" ):Value

and post the results here.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: DBF to SQL script tool

Postby cdmmaui » Fri Jun 27, 2014 11:25 am

Mr. Rao,

I am getting the following error when trying to display 'DBMS Name'

Application
===========
Path and name: C:\Winapps\cargo\data\cdmsql.exe (32 bits)
Size: 2,547,200 bytes
Compiler version: xHarbour 1.2.3 Intl. (SimpLex) (Build 20130422)
FiveWin Version: FWHX 14.06
Windows version: 6.1, Build 7601 Service Pack 1

Time from start: 0 hours 0 mins 5 secs
Error occurred at: 06/27/2014, 06:20:10
Error description: Error BASE/1004 Class: 'NIL' has no exported method: PROPERTIES
Args:
[ 1] = U
[ 2] = C DBMS Name

Stack Calls
===========
Called from: => PROPERTIES( 0 )
Called from: cdmsql.prg => _SQLSCRIPT( 102 )
Called from: cdmsql.prg => (b)MAIN( 54 )
Called from: .\source\classes\MENU.PRG => TMENU:COMMAND( 463 )
Called from: .\source\classes\WINDOW.PRG => TWINDOW:COMMAND( 1050 )
Called from: => TWINDOW:HANDLEEVENT( 0 )
Called from: .\source\classes\WINDOW.PRG => _FWH( 3279 )
Called from: => WINRUN( 0 )
Called from: .\source\classes\WINDOW.PRG => TWINDOW:ACTIVATE( 1003 )
Called from: cdmsql.prg => MAIN( 72 )
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
User avatar
cdmmaui
 
Posts: 689
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong

Re: DBF to SQL script tool

Postby cdmmaui » Fri Jun 27, 2014 11:27 am

Mr. Rao,

I get the following error when trying to display Extended Properties

Application
===========
Path and name: C:\Winapps\cargo\data\cdmsql.exe (32 bits)
Size: 2,547,200 bytes
Compiler version: xHarbour 1.2.3 Intl. (SimpLex) (Build 20130422)
FiveWin Version: FWHX 14.06
Windows version: 6.1, Build 7601 Service Pack 1

Time from start: 0 hours 0 mins 3 secs
Error occurred at: 06/27/2014, 06:25:43
Error description: Error BASE/1004 Class: 'NIL' has no exported method: PROPERTIES
Args:
[ 1] = U
[ 2] = C Extended Properties

Stack Calls
===========
Called from: => PROPERTIES( 0 )
Called from: cdmsql.prg => _SQLSCRIPT( 103 )
Called from: cdmsql.prg => (b)MAIN( 54 )
Called from: .\source\classes\MENU.PRG => TMENU:COMMAND( 463 )
Called from: .\source\classes\WINDOW.PRG => TWINDOW:COMMAND( 1050 )
Called from: => TWINDOW:HANDLEEVENT( 0 )
Called from: .\source\classes\WINDOW.PRG => _FWH( 3279 )
Called from: => WINRUN( 0 )
Called from: .\source\classes\WINDOW.PRG => TWINDOW:ACTIVATE( 1003 )
Called from: cdmsql.prg => MAIN( 72 )
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
User avatar
cdmmaui
 
Posts: 689
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong

Re: DBF to SQL script tool

Postby nageswaragunupudi » Sat Jun 28, 2014 12:08 am

That means oCn is NIL and that in turn means you could not successfully connect to the mssql server.

After using oCn := FW_OpenAdoConnection( cStr )
we need to check:
if oCn == nil
// connecton failed. take appropriate action
else
// connection succeeded. Proceed with next work
endif

You failed to connect to the server because your connection string ( cSqlCon := "Server=0.0.0.0;Database=CDMWINFRT;User Id=xxxxxxxxxx;Password=xxxxxxxxxx;" is wrong.

Typical connection string to MSSql server looks like this:
Provider=sqloledb;Data Source=myServerAddress;Initial Catalog=myDataBase;
User Id=myUsername;Password=myPassword;
You may refer to http://www.connectionstrings.com/sql-server/ for more information.

In case you like FWH to construct the connection string for you, you can use this syntax:

ADOCONNECT oCn TO MSSQL SERVER <sqlservername>
DATABASE <initialcatalog> USER <username,eg:SA> PASSWORD <password>

After successful connection to the server, then you can use any other ado functions. If oCn != nil, the connection is successful.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 39 guests