ODBC Connection to dbase IV?

This is a discussion on ODBC Connection to dbase IV? within the PHP Language forums, part of the PHP Programming Forums category; I am trying to figure out how to query some data out of a dbase IV (.dbf) file sitting on ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-15-2008
bcbrock@gmail.com
 
Posts: n/a
Default ODBC Connection to dbase IV?

I am trying to figure out how to query some data out of a dbase IV
(.dbf) file sitting on a remote server from my MySQL/PHP/Web Server.

Both servers are Windows Server 2003 SP2.

My MySQL/PHP/Web server is running PHP 4.3.11, MySQL 4.0.24, and IIS.

I have set a system DSN on the remote machine for the directory that
contains the dbase file. The DSN name is SASIxp, and the actual file
I'm trying to connect to is ADST.DBF.

I've found several examples of how to connect with other database
types, and have used those examples in an attempt to connect to my
dbase IV file, but so far, I'm not having any luck. Instead, I'm
getting errors like:

Code:
Warning: odbc_exec(): SQL error: [Microsoft][ODBC dBase Driver]
The Microsoft Jet database engine could not find the object
'ADST.DBF'. Make sure the object exists and that you spell its name
and the path name correctly., SQL state S0002 in SQLExecDirect in E:
\InetPub\wwwroot\posa_test\includes\functions.inc on line 4952
I'm including my sandbox code below, which includes 4 different
versions of $connection_string, none of which have worked. :(

Does anybody know of a good tutorial, or have any suggestions? I know
I'm somewhat limited in what I can do with a dbase IV file (if
anything???), but all I really need is to do a simple lookup; no
adding, deleting or changing of any records.


Code:
//$connection_string = 'DRIVER={Microsoft dBase Driver
(*.dbf)};SERVER=<10.112.139.230>;DATABASE=<ADST.DBF>';
//$connection_string = 'DRIVER={Microsoft dBase Driver
(*.dbf)};SERVER=<10.112.139.230>;DATABASE=<SASIxp>';

//$connection_string = 'DRIVER={Microsoft dBase Driver
(*.dbf)};datasource=SASIxp;';

$connection_string = 'DRIVER={Microsoft dBase Driver (*.dbf)};
datasource=\\\\sasi_main\\sasixp\\datafile\\ADST.DBF;';


$user = '';
$pass = '';

//$connection = odbc_connect( $connection_string, $user, $pass );

$odbc = odbc_connect ($connection_string, '', '') or die('Could Not
Connect to ODBC Database!');

$strsql= 'SELECT * FROM ADST.DBF';

$query = odbc_exec($odbc, $strsql) or die (odbc_errormsg());
Thanks in advance for your assistance!: :)
Reply With Quote
  #2 (permalink)  
Old 01-15-2008
Richard
 
Posts: n/a
Default Re: ODBC Connection to dbase IV?


<bcbrock@gmail.com> wrote in message
news:24c1f4c1-883f-4c8f-9161-2c8aa8b4b742@u10g2000prn.googlegroups.com...
>I am trying to figure out how to query some data out of a dbase IV
> (.dbf) file sitting on a remote server from my MySQL/PHP/Web Server.
>
> Both servers are Windows Server 2003 SP2.
>
> My MySQL/PHP/Web server is running PHP 4.3.11, MySQL 4.0.24, and
> IIS.
>
> I have set a system DSN on the remote machine for the directory that
> contains the dbase file. The DSN name is SASIxp, and the actual
> file
> I'm trying to connect to is ADST.DBF.
>
> I've found several examples of how to connect with other database
> types, and have used those examples in an attempt to connect to my
> dbase IV file, but so far, I'm not having any luck. Instead, I'm
> getting errors like:
>
>
Code:
Warning: odbc_exec(): SQL error: [Microsoft][ODBC dBase
> Driver]
> The Microsoft Jet database engine could not find the object
> 'ADST.DBF'. Make sure the object exists and that you spell its name
> and the path name correctly., SQL state S0002 in SQLExecDirect in E:
> \InetPub\wwwroot\posa_test\includes\functions.inc on line
> 4952
>
> I'm including my sandbox code below, which includes 4 different
> versions of $connection_string, none of which have worked. :(
>
> Does anybody know of a good tutorial, or have any suggestions? I
> know
> I'm somewhat limited in what I can do with a dbase IV file (if
> anything???), but all I really need is to do a simple lookup; no
> adding, deleting or changing of any records.
>
>
>
Code:
> //$connection_string = 'DRIVER={Microsoft dBase Driver
> (*.dbf)};SERVER=<10.112.139.230>;DATABASE=<ADST.DBF>';
> //$connection_string = 'DRIVER={Microsoft dBase Driver
> (*.dbf)};SERVER=<10.112.139.230>;DATABASE=<SASIxp>';
>
> //$connection_string = 'DRIVER={Microsoft dBase Driver
> (*.dbf)};datasource=SASIxp;';
>
> $connection_string = 'DRIVER={Microsoft dBase Driver (*.dbf)};
> datasource=\\\\sasi_main\\sasixp\\datafile\\ADST.DBF;';
>
>
> $user = '';
> $pass = '';
>
> //$connection = odbc_connect( $connection_string, $user, $pass );
>
> $odbc = odbc_connect ($connection_string, '', '') or die('Could Not
> Connect to ODBC Database!');
>
> $strsql= 'SELECT * FROM ADST.DBF';
>
> $query = odbc_exec($odbc, $strsql) or die (odbc_errormsg());
>
> Thanks in advance for your assistance!: :)


The ODBC driver probably doesnt like the UNC path, and wants a local
file.
Check google for this.

Richard.


Reply With Quote
  #3 (permalink)  
Old 01-15-2008
Richard
 
Posts: n/a
Default Re: ODBC Connection to dbase IV?


"Richard" <root@localhost> wrote in message
news:478d3709$0$14353$dbd4f001@news.euronet.nl...
>
> <bcbrock@gmail.com> wrote in message
> news:24c1f4c1-883f-4c8f-9161-2c8aa8b4b742@u10g2000prn.googlegroups.com...
>>I am trying to figure out how to query some data out of a dbase IV
>> (.dbf) file sitting on a remote server from my MySQL/PHP/Web
>> Server.
>>
>> Both servers are Windows Server 2003 SP2.
>>
>> My MySQL/PHP/Web server is running PHP 4.3.11, MySQL 4.0.24, and
>> IIS.
>>
>> I have set a system DSN on the remote machine for the directory
>> that
>> contains the dbase file. The DSN name is SASIxp, and the actual
>> file
>> I'm trying to connect to is ADST.DBF.
>>
>> I've found several examples of how to connect with other database
>> types, and have used those examples in an attempt to connect to my
>> dbase IV file, but so far, I'm not having any luck. Instead, I'm
>> getting errors like:
>>
>>
Code:
Warning: odbc_exec(): SQL error: [Microsoft][ODBC dBase
>> Driver]
>> The Microsoft Jet database engine could not find the object
>> 'ADST.DBF'. Make sure the object exists and that you spell its name
>> and the path name correctly., SQL state S0002 in SQLExecDirect in
>> E:
>> \InetPub\wwwroot\posa_test\includes\functions.inc on line
>> 4952
>>
>> I'm including my sandbox code below, which includes 4 different
>> versions of $connection_string, none of which have worked. :(
>>
>> Does anybody know of a good tutorial, or have any suggestions? I
>> know
>> I'm somewhat limited in what I can do with a dbase IV file (if
>> anything???), but all I really need is to do a simple lookup; no
>> adding, deleting or changing of any records.
>>
>>
>>
Code:
>> //$connection_string = 'DRIVER={Microsoft dBase Driver
>> (*.dbf)};SERVER=<10.112.139.230>;DATABASE=<ADST.DBF>';
>> //$connection_string = 'DRIVER={Microsoft dBase Driver
>> (*.dbf)};SERVER=<10.112.139.230>;DATABASE=<SASIxp>';
>>
>> //$connection_string = 'DRIVER={Microsoft dBase Driver
>> (*.dbf)};datasource=SASIxp;';
>>
>> $connection_string = 'DRIVER={Microsoft dBase Driver (*.dbf)};
>> datasource=\\\\sasi_main\\sasixp\\datafile\\ADST.DBF;';
>>
>>
>> $user = '';
>> $pass = '';
>>
>> //$connection = odbc_connect( $connection_string, $user, $pass );
>>
>> $odbc = odbc_connect ($connection_string, '', '') or die('Could Not
>> Connect to ODBC Database!');
>>
>> $strsql= 'SELECT * FROM ADST.DBF';
>>
>> $query = odbc_exec($odbc, $strsql) or die (odbc_errormsg());
>>
>> Thanks in advance for your assistance!: :)

>
> The ODBC driver probably doesnt like the UNC path, and wants a local
> file.
> Check google for this.
>
> Richard.
>


BTW,
if you have setup the datasource correctly, you only have to use its
name in PHP, and user and pass if needed.
The data directory etc. you specify in the DSN.

I found this in the archives here, maybe good starting point:
Datasource name= 'Packlists' , user = '', pass = ''
----------------------------------

$odbc=odbc_connect('Packlists','','');
$q="select * from packlist01;";
$odbcset=odbc_exec($odbc,$q);

odbc_fetch_into($odbcset,$row);
for ($i=1; $i<=odbc_num_fields($odbcset); $i++)
{
$field[odbc_field_name($odbcset,$i)] = $row[($i-1)];
}
odbc_close($odbc);


----------------------------------

Good luck
Richard.


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 09:50 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0