Where i can find "FiveODBC Documentation"

User avatar
max
Posts: 122
Joined: Fri Jun 30, 2006 2:14 pm
Location: Ancona - Italy

Where i can find "FiveODBC Documentation"

Post by max »

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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Where i can find "FiveODBC Documentation"

Post by Antonio Linares »

Max,

FWH current ADO support is the way to go:

http://forums.fivetechsupport.com/viewt ... =3&t=32657
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
max
Posts: 122
Joined: Fri Jun 30, 2006 2:14 pm
Location: Ancona - Italy

Re: Where i can find "FiveODBC Documentation"

Post by max »

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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Where i can find "FiveODBC Documentation"

Post by Antonio Linares »

Max,

1) Yes

2) Yes
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
max
Posts: 122
Joined: Fri Jun 30, 2006 2:14 pm
Location: Ancona - Italy

Re: Where i can find "FiveODBC Documentation"

Post by max »

Ok Antonio: upgrade order done.

Bye
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Where i can find "FiveODBC Documentation"

Post by Antonio Linares »

Max,

Many thanks

Please review fwh\samples\mariainv.prg

There you have an ADO full working example :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
max
Posts: 122
Joined: Fri Jun 30, 2006 2:14 pm
Location: Ancona - Italy

Re: Where i can find "FiveODBC Documentation"

Post by max »

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?
admsoporte
Posts: 79
Joined: Sun Oct 09, 2005 3:09 pm
Location: Mexico

Re: Where i can find "FiveODBC Documentation"

Post by admsoporte »

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
User avatar
max
Posts: 122
Joined: Fri Jun 30, 2006 2:14 pm
Location: Ancona - Italy

Re: Where i can find "FiveODBC Documentation"

Post by max »

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
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Where i can find "FiveODBC Documentation"

Post by Enrico Maria Giordano »

You have to use a connection string like this:

Code: Select all

Provider=sqloledb;Data Source=<ipaddress>;Initial Catalog=<databasename>;User Id=<userid>;Password=<password>
EMG
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Where i can find "FiveODBC Documentation"

Post by Enrico Maria Giordano »

A code sample (not working):

Code: Select all

// 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
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Where i can find "FiveODBC Documentation"

Post by nageswaragunupudi »

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: Select all

#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: Select all

#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
User avatar
max
Posts: 122
Joined: Fri Jun 30, 2006 2:14 pm
Location: Ancona - Italy

Re: Where i can find "FiveODBC Documentation"

Post by max »

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.
User avatar
max
Posts: 122
Joined: Fri Jun 30, 2006 2:14 pm
Location: Ancona - Italy

Re: Where i can find "FiveODBC Documentation"

Post by max »

Sorry, I solved by adding REQUEST DBFCDX that was missing.
User avatar
max
Posts: 122
Joined: Fri Jun 30, 2006 2:14 pm
Location: Ancona - Italy

Re: Where i can find "FiveODBC Documentation"

Post by max »

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
Post Reply