FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Moving DBFCDX to MS SQL
Posts: 708
Joined: Fri Oct 28, 2005 09:53 AM
Moving DBFCDX to MS SQL
Posted: Mon Mar 25, 2013 03:56 AM

Hello Everyone,

I am moving DBFCDX to MS SQL and I was hoping to get some feedback on the best way to TOleAuto connection, recordset, open and data refresh

  1. Is the best way to establish SQL connection and execute SQL statement

TRY
oSql:=TOleAuto():New("ADODB.Recordset")
CATCH
MsgInfo("It seems that your PC does not have MDAC installed OR MDAC is corrupted.")
RETURN (.F.)
END
MsgInfo( "ADODB.Recordset OK!")

// Set...
oSql:CursorType := 1 // opendkeyset
oSql:CursorLocation := 3 // local cache
oSql:LockType := 3 // lock opportunistic

// Set SQL string...
cSql := "SELECT * FROM SalesOrderHeader"
TRY
oSql:Open( cSql, 'Provider='+xPROVIDER+';Data Source='+xSOURCE+';Initial Catalog='+xCATALOG+';User Id='+xUSERID+';Password='+xPASSWORD )
CATCH oError
MsgWait("Failed to Connect to the Database")
RETURN (.F.)
END
MsgInfo( oSql:RecordCount )

  1. Can I use same oSql to execute another SQL statement on another table?

  2. How do I handle data refreshes from the SQL statement in item 1. ( "SELECT * FROM SalesOrderHeader" )

Thank you,

*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Moving DBFCDX to MS SQL
Posted: Mon Mar 25, 2013 08:40 AM
cdmmaui wrote:2. Can I use same oSql to execute another SQL statement on another table?


Yes, but you have to oSql:Close() first.

cdmmaui wrote:3. How do I handle data refreshes from the SQL statement in item 1. ( "SELECT * FROM SalesOrderHeader" )


It depends on the CursorType. Have a look at MSDN docs.

EMG
Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
Re: Moving DBFCDX to MS SQL
Posted: Mon Mar 25, 2013 09:07 AM
cdmmaui wrote:
3. How do I handle data refreshes from the SQL statement in item 1. ( "SELECT * FROM SalesOrderHeader" )


For the refresh you can use :
Code (fw): Select all Collapse
oSql:Requery()
Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite

Continue the discussion