FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for CA-Clipper Where i can find "FiveODBC Documentation"
Posts: 130
Joined: Fri Jun 30, 2006 02:14 PM
Where i can find "FiveODBC Documentation"
Posted: Wed Aug 22, 2018 05:17 PM

I'd like to know more about FiveODBC classes. Opening the file help file of FiveWin Classes i find the class TdbOdbc, TOdbc, ecc. but the manual suggest "Please consult FiveODBC Documentation". Where i can find it? I search online into "Fivetech Software Wiki" too, but i didn't find Five ODBC Documentation.
Thank you!
Max

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Where i can find "FiveODBC Documentation"
Posted: Thu Aug 23, 2018 02:39 PM

Max,

FWH current ADO support is the way to go:

viewtopic.php?f=3t=32657

&

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 130
Joined: Fri Jun 30, 2006 02:14 PM
Re: Where i can find "FiveODBC Documentation"
Posted: Fri Aug 24, 2018 10:35 AM

Antonio,
two questions:
1) i'm using FWH version 15.06. I have to upgrade my version for ADO support in FWH ?
2) Superflous i think, but just to be sure: is it ok and recommended with databases "SQL Server" too?

Thank you
Max

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Where i can find "FiveODBC Documentation"
Posted: Fri Aug 24, 2018 10:57 AM

Max,

1) Yes

2) Yes

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 130
Joined: Fri Jun 30, 2006 02:14 PM
Re: Where i can find "FiveODBC Documentation"
Posted: Fri Aug 24, 2018 12:05 PM

Ok Antonio: upgrade order done.

Bye

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Where i can find "FiveODBC Documentation"
Posted: Fri Aug 24, 2018 02:06 PM

Max,

Many thanks

Please review fwh\samples\mariainv.prg

There you have an ADO full working example :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 130
Joined: Fri Jun 30, 2006 02:14 PM
Re: Where i can find "FiveODBC Documentation"
Posted: Sat Aug 25, 2018 06:55 PM

The example inside mariainv.prg seems to work only with "MySQL Server", isn't it? Instead, i need to connect to an SQL SERVER database.
I try compiling the form of mariainv "own server" with cHost,cuser,cpassword,cdb variables but alwais receive an error like this:
"2003 Can't connect to MySQL server on 'NAMEPC' (10061)" , where NAMEPC=name of my pc that run SQL SERVER 2017 EXPRESS EDITION .
Maybe FWCONNECT works only with Mysql and not with Sql Server?
Where am i wrong?

Posts: 111
Joined: Sun Oct 09, 2005 03:09 PM
Re: Where i can find "FiveODBC Documentation"
Posted: Sat Aug 25, 2018 11:36 PM
max wrote:The example inside mariainv.prg seems to work only with "MySQL Server", isn't it? Instead, i need to connect to an SQL SERVER database.
I try compiling the form of mariainv "own server" with cHost,cuser,cpassword,cdb variables but alwais receive an error like this:
"2003 Can't connect to MySQL server on 'NAMEPC' (10061)" , where NAMEPC=name of my pc that run SQL SERVER 2017 EXPRESS EDITION .
Maybe FWCONNECT works only with Mysql and not with Sql Server?
Where am i wrong?
Me parece que el soporte a MySQL nativo es a partir de FWH1612

Enviado desde mi FIG-LX3 mediante Tapatalk
Saludos

Atentamente

Jose F Dominguez Serafin

email admsoporte@gmail.com
Posts: 130
Joined: Fri Jun 30, 2006 02:14 PM
Re: Where i can find "FiveODBC Documentation"
Posted: Sun Aug 26, 2018 10:16 AM

Jose,
i'm using latest FWH release: 1805. And i need native support for SQL SERVER, not for "MySQL".
I access to my database SQL via ODBC regularly, but today the best way is to access via ADO.
But how? I need just an example of native connection to SQL SERVER database, avoiding to configure ODBC.
In \fwh\samples i find only examples for db MySQL via FWCONNECT.

Thank you.

Max

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Where i can find "FiveODBC Documentation"
Posted: Sun Aug 26, 2018 11:00 AM
You have to use a connection string like this:

Code (fw): Select all Collapse
Provider=sqloledb;Data Source=<ipaddress>;Initial Catalog=<databasename>;User Id=<userid>;Password=<password>


EMG
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Where i can find &quot;FiveODBC Documentation&quot;
Posted: Sun Aug 26, 2018 11:03 AM
A code sample (not working):

Code (fw): Select all Collapse
// ADO definitions

#define adOpenForwardOnly 0
#define adOpenKeyset      1
#define adOpenDynamic     2
#define adOpenStatic      3

#define adLockReadOnly        1
#define adLockPessimistic     2
#define adLockOptimistic      3
#define adLockBatchOptimistic 4

#define adUseNone   1
#define adUseServer 2
#define adUseClient 3


oRs = CREATEOBJECT( "ADODB.Recordset" )

oRs:CursorLocation = adUseClient

oRs:Open( "SELECT * FROM YourTable", cConnectionString, adOpenForwardOnly, adLockReadOnly )

? oRs:Fields( "MyField" ):Value

oRs:Close()


EMG
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Where i can find &quot;FiveODBC Documentation&quot;
Posted: Sun Aug 26, 2018 10:18 PM
Connecting to Microsoft SQL server using FWH simplified ADO functions.


FWH provides a single line function FW_OpenAdoConnection( <parame,,,> ) to connect to any server, MSSQL, ORACLE, MYSQL,MSACCESS, etc.

In case of MSSQL, the server can be configured to login using Windows Authentication (also called Integrated Security) and/or using Username and password. Later is preferable.

The following sample (ado1.prg) demonstrates connecting to MSSQL server using this function and then view all the databases available on the server and also to create a new database "FWHADO" for further tests.

ado1.prg:
Code (fw): Select all Collapse
#include "fivewin.ch"
#include "adodef.ch"

static oCn

//----------------------------------------------------------------------------//

function Main()

   local cServer     := "SQLEXPRESS"  // your server address
   local cInitialDB  := ""            // for now we keep it empty
   local cUser       := "SA"
   local cPassword   := "password"  // your password
   local aCredentials, aDB

   // If connecting by Windows authentication (Integrated Security)
   aCredentials   := { "MSSQL", cServer, cInitialDB }
   // If connecting by Username and Password
   aCredentials   := { "MSSQL", cServer, cInitialDB, cUser, cPassword }

   ? "Trying to connect"
   oCn            := FW_OpenAdoConnection( aCredentials, .T. )
   if oCn == nil
      ? "Failed to connect"
      return nil
   endif

   ? "Successfully connected to server"

   // Let us view list of databases existing on the server
   aDB      := FW_AdoCatalogs( oCn )

   XBROWSER aDB TITLE "List of databases"

   if AScan( aDB, { |c| Upper( c ) == "FWHADO" } ) == 0
      // Database FWHADO does not exist
      // We crete it now

      oCn:Execute( "CREATE DATABASE FWHADO" )
      ? "Created Database FWHADO"
   endif

   oCn:Close()

return nil

//----------------------------------------------------------------------------//


If the above sample successfully works, then we can go to the second example (ado2.prg).
This sample connects to the server with initial database FWHADO, imports one DBF from the \fwh\samples folder and opens the newly imported table for edit. We can edit, append new records as we like.

ado2.prg
Code (fw): Select all Collapse
#include "fivewin.ch"
#include "adodef.ch"

REQUEST DBFCDX

static oCn

//----------------------------------------------------------------------------//

function Main()

   local cServer     := "SQLEXPRESS"  // your server address
   local cInitialDB  := "FWHADO"
   local cUser       := "SA"
   local cPassword   := "password"  // your password
   local aCredentials, oRs

   // If connecting by Windows authentication (Integrated Security)
   aCredentials   := { "MSSQL", cServer, cInitialDB }
   // If connecting by Username and Password
   aCredentials   := { "MSSQL", cServer, cInitialDB, cUser, cPassword }

   ? "Trying to connect"
   oCn            := FW_OpenAdoConnection( aCredentials, .T. )
   if oCn == nil
      ? "Failed to connect"
      return nil
   endif

   ? "Successfully connected to server"
   ? "Importing DBF"

   FW_AdoImportFromDBF( oCn, "c:\fwh\samples\states.dbf" ) // give your dbf with full path

   // Open table
   oRs   := FW_OpenRecordSet( oCn, "SELECT * FROM STATES" )
   if oRs == nil
      ? "Failed to open table"
   else
      XBROWSER oRs FASTEDIT AUTOSORT
      oRs:Close()
   endif

   oCn:Close()

return nil

//----------------------------------------------------------------------------//


We can view all the ADO functions in \fwh\source\function\adofuncs.prg

To learn all about ADO
https://www.w3schools.com/asp/ado_intro.asp
Regards



G. N. Rao.

Hyderabad, India
Posts: 130
Joined: Fri Jun 30, 2006 02:14 PM
Re: Where i can find &quot;FiveODBC Documentation&quot;
Posted: Wed Jan 09, 2019 09:10 PM

I'm testing ADO functions for accessing to a database of SQL SERVER. Ado1.prg and ado2.prg run ok! Now i need to export a table to a dbf, so i'm trying to use FW_ADOExportToDbf function.

At Runtime, i receive msgbox error "DBFCDX needs to be linked" , but i already have DBFCDX.LIB linked in my exe ! Where i'm wrong??

Thank you.

Posts: 130
Joined: Fri Jun 30, 2006 02:14 PM
Re: Where i can find &quot;FiveODBC Documentation&quot;
Posted: Fri Jan 11, 2019 06:02 PM

Sorry, I solved by adding REQUEST DBFCDX that was missing.

Posts: 130
Joined: Fri Jun 30, 2006 02:14 PM
Re: Where i can find &quot;FiveODBC Documentation&quot;
Posted: Wed Apr 24, 2019 01:48 PM

Rao,
ado functions are great for accessing SQL, thank you! Import from dbf, export and browse are ok and it run very fast.
Now I need two examples, if possible:
1) how can i add records to an existing table of a database SQL in "batch" mode (not interactively with browse and similar)?
2) how can i replace a content of a field in a specific record of an existing table (like "replace fieldname with variablename" in a dbf)?

Someone have an example to post?

Thank you