Where i can find "FiveODBC Documentation"

Where i can find "FiveODBC Documentation"

Postby max » Wed Aug 22, 2018 5: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
User avatar
max
 
Posts: 128
Joined: Fri Jun 30, 2006 2:14 pm
Location: Ancona - Italy

Re: Where i can find "FiveODBC Documentation"

Postby Antonio Linares » Thu Aug 23, 2018 2:39 pm

Max,

FWH current ADO support is the way to go:

viewtopic.php?f=3&t=32657
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42111
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Where i can find "FiveODBC Documentation"

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

Re: Where i can find "FiveODBC Documentation"

Postby Antonio Linares » Fri Aug 24, 2018 10:57 am

Max,

1) Yes

2) Yes
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42111
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Where i can find "FiveODBC Documentation"

Postby max » Fri Aug 24, 2018 12:05 pm

Ok Antonio: upgrade order done.

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

Re: Where i can find "FiveODBC Documentation"

Postby Antonio Linares » Fri Aug 24, 2018 2: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42111
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Where i can find "FiveODBC Documentation"

Postby max » Sat Aug 25, 2018 6: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?
User avatar
max
 
Posts: 128
Joined: Fri Jun 30, 2006 2:14 pm
Location: Ancona - Italy

Re: Where i can find "FiveODBC Documentation"

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

Re: Where i can find "FiveODBC Documentation"

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

Re: Where i can find "FiveODBC Documentation"

Postby Enrico Maria Giordano » Sun Aug 26, 2018 11:00 am

You have to use a connection string like this:

Code: Select all  Expand view  RUN
Provider=sqloledb;Data Source=<ipaddress>;Initial Catalog=<databasename>;User Id=<userid>;Password=<password>


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8716
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Where i can find "FiveODBC Documentation"

Postby Enrico Maria Giordano » Sun Aug 26, 2018 11:03 am

A code sample (not working):

Code: Select all  Expand view  RUN
// 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
Enrico Maria Giordano
 
Posts: 8716
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Where i can find "FiveODBC Documentation"

Postby nageswaragunupudi » 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: Select all  Expand view  RUN
#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  Expand view  RUN
#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
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Where i can find "FiveODBC Documentation"

Postby max » Wed Jan 09, 2019 9: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.
User avatar
max
 
Posts: 128
Joined: Fri Jun 30, 2006 2:14 pm
Location: Ancona - Italy

Re: Where i can find "FiveODBC Documentation"

Postby max » Fri Jan 11, 2019 6:02 pm

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

Re: Where i can find "FiveODBC Documentation"

Postby max » Wed Apr 24, 2019 1: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
User avatar
max
 
Posts: 128
Joined: Fri Jun 30, 2006 2:14 pm
Location: Ancona - Italy

Next

Return to FiveWin for CA-Clipper

Who is online

Users browsing this forum: No registered users and 7 guests