Moving DBFCDX to MS SQL

Moving DBFCDX to MS SQL

Postby cdmmaui » Mon Mar 25, 2013 3: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 )

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

3. 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
User avatar
cdmmaui
 
Posts: 689
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong

Re: Moving DBFCDX to MS SQL

Postby Enrico Maria Giordano » Mon Mar 25, 2013 8: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
User avatar
Enrico Maria Giordano
 
Posts: 8713
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Moving DBFCDX to MS SQL

Postby Marc Vanzegbroeck » Mon Mar 25, 2013 9: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: Select all  Expand view
oSql:Requery()
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 93 guests