FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Using ODBC to connect to DBF via Internet
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Using ODBC to connect to DBF via Internet
Posted: Wed Aug 17, 2016 10:11 PM

I need to connect to ODBC via the Internet, to send & receive data from DBFs. The Internet connection will be sending SQL commands thus the need for the ODBC connection. The Internet connection will be via a third-party product so I don't have any options there.

Questions:

1) Can this be done?

2) Alternately, perhaps we could use a SQL database for the third-party product to connect to, then move the data back and forth to the DBFs?

3) Does anyone have any sample code, and/or other ideas of how to do this?

I have searched the forum and couldn't find any references to this type of connection.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Using ODBC to connect to DBF via Internet
Posted: Thu Aug 18, 2016 01:56 PM
James

We used to use Ms Access .mdb for some of our local intranet apps .. don't see why it would not work using an IP address from the outside tunnel using ADO .. perhaps something like this behind your HTML :

Code (fw): Select all Collapse
xPROVIDER := "Microsoft.Jet.OLEDB.4.0"
xSOURCE   := "\\10.1.0.0\share\folder\Your.mdb"  // use your IP address
xPASSWORD := "whatever"

xString := 'Provider='+xPROVIDER+';Data Source='+xSOURCE+';Jet OLEDB:Database Password='+xPASSWORD

// global connection string
oCn := CREATEOBJECT( "ADODB.Connection" )

TRY
   oCn:Open( xString )
CATCH oErr
   Saying := "Could not open a Global Connection to Database "+xSource
   MsgInfo( Saying )
   RETURN(.F.)
END TRY


Granted you probably could not use the above exact code in your HTML but I am sure there are some work arounds .. All the above code gets you is the connection to the MS Access database and from there you can use your ado connection to create a oRs ( recordset ) to be able to interact with .Dbf ..

The above is only meant as a concept no ODBC needed .. native ADO.

Rick Lipkin
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Using ODBC to connect to DBF via Internet
Posted: Thu Aug 18, 2016 06:00 PM

Rick,

I have not done this sort of thing before, and I don't think I was clear.

We have a third-party vendor that needs to read and write to our DBFs via the Internet. They are used to doing this when accessing SQL databases but we need them to access our DBFs in an existing application.

So, can we do this via ADO?

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
Re: Using ODBC to connect to DBF via Internet
Posted: Thu Aug 18, 2016 09:15 PM
James,

I never used it, but there is a connectionstring for a DBF

https://www.connectionstrings.com/dbf-foxpro/
Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Using ODBC to connect to DBF via Internet
Posted: Thu Aug 18, 2016 09:18 PM

Yes, you can use Microsoft Visual FoxPro Driver. Install it on the web server (if you are allowed to do it) and use the following connection string:

Driver={Microsoft Visual FoxPro Driver};SourceType=DBF;SourceDb=<dbfpath>

EMG

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Using ODBC to connect to DBF via Internet
Posted: Tue Aug 30, 2016 09:59 PM

ADO and Indexes

Does anyone know, if you update DBFs via ADO, are the indexes updated too? If so, how does this work--is there a configuration file that tells the ADO which indexes go with the DBF. Which index types are supported, ntx, cdx, ?

I have been searching the internet but can't find these answers.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Using ODBC to connect to DBF via Internet
Posted: Wed Aug 31, 2016 08:04 AM

As far as I know, no, you can't use/update DBF indexes using ADO.

EMG

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Using ODBC to connect to DBF via Internet
Posted: Wed Aug 31, 2016 02:13 PM

Thanks, Enrico. That was my fear. Although you can write data, if you can't update indexes, it seems that using ADO has little value except for reading data.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM
Re: Using ODBC to connect to DBF via Internet
Posted: Wed Aug 31, 2016 02:26 PM

I think it depends on the driver. I know the jet engine can update dbf index files. If you have Advanced Database Server you can also provide remote access via ODBC client or OLE DB client for ADO.

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Using ODBC to connect to DBF via Internet
Posted: Wed Aug 31, 2016 03:09 PM
James Bott wrote:Thanks, Enrico. That was my fear. Although you can write data, if you can't update indexes, it seems that using ADO has little value except for reading data.

James


ADO is useful when you have to do with SQL. And SQL doesn't need of (external) indexes.

EMG
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Using ODBC to connect to DBF via Internet
Posted: Wed Aug 31, 2016 03:12 PM
Gale FORd wrote:I think it depends on the driver. I know the jet engine can update dbf index files. If you have Advanced Database Server you can also provide remote access via ODBC client or OLE DB client for ADO.


Yes, that's true, it depends on the driver. But I don't know of any driver capable to update DBF indexes concurrently with [x]Harbour or similar. Maybe ADS, but I'm not familiar with it.

EMG
Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM
Re: Using ODBC to connect to DBF via Internet
Posted: Wed Aug 31, 2016 04:23 PM

The jet driver and some others allow you to connect to different Foxpro and dBase version. Would have to match up the locking schemes.

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Using ODBC to connect to DBF via Internet
Posted: Wed Aug 31, 2016 05:00 PM

Gale,

Are you suggesting that the Jet ODBC driver could be used by SQL engines other than Access?

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM
Re: Using ODBC to connect to DBF via Internet
Posted: Wed Aug 31, 2016 07:33 PM
Yes, Jet is just 1 of many Providers.
There is also Ace. An example connection string for dBase:
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\folder;
Extended Properties=dBASE IV;User ID=Admin;

I also found example SQL statement for remote access using Microsoft ODBC driver.
Remote Drives

Driver={Microsoft dBase Driver (*.dbf)};datasource=dBase Files;

Then the SQL syntax example: "select * from \\remotemachine\thefile.dbf"

There are some issues with indexes. Not much help but here are a couple of links.
https://www.connectionstrings.com/dbf-foxpro/
http://www.motobit.com/tips/detpg_asp-dbf-database/
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Using ODBC to connect to DBF via Internet
Posted: Wed Aug 31, 2016 11:04 PM

Tanks, Gale, all good information.

We may not have to deal with indexes. We may just put the incoming data into batch files and process them in the FWH app. Still being able to use indexes would be great.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10