By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,221 Members | 1,211 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,221 IT Pros & Developers. It's quick & easy.

ODBC Connection to dbase IV?

P: n/a
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:

Expand|Select|Wrap|Line Numbers
  1. Warning: odbc_exec(): SQL error: [Microsoft][ODBC dBase Driver]
  2. The Microsoft Jet database engine could not find the object
  3. 'ADST.DBF'. Make sure the object exists and that you spell its name
  4. and the path name correctly., SQL state S0002 in SQLExecDirect in E:
  5. \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.
Expand|Select|Wrap|Line Numbers
  1. //$connection_string = 'DRIVER={Microsoft dBase Driver
  2. (*.dbf)};SERVER=<10.112.139.230>;DATABASE=<ADST.DBF>';
  3. //$connection_string = 'DRIVER={Microsoft dBase Driver
  4. (*.dbf)};SERVER=<10.112.139.230>;DATABASE=<SASIxp>';
  5.  
  6. //$connection_string = 'DRIVER={Microsoft dBase Driver
  7. (*.dbf)};datasource=SASIxp;';
  8.  
  9. $connection_string = 'DRIVER={Microsoft dBase Driver (*.dbf)};
  10. datasource=\\\\sasi_main\\sasixp\\datafile\\ADST.DBF;';
  11.  
  12.  
  13. $user = '';
  14. $pass = '';
  15.  
  16. //$connection = odbc_connect( $connection_string, $user, $pass );
  17.  
  18. $odbc = odbc_connect ($connection_string, '', '') or die('Could Not
  19. Connect to ODBC Database!');
  20.  
  21. $strsql= 'SELECT * FROM ADST.DBF';
  22.  
  23. $query = odbc_exec($odbc, $strsql) or die (odbc_errormsg());
Thanks in advance for your assistance!: :)
Jan 15 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a

<bc*****@gmail.comwrote in message
news:24**********************************@u10g2000 prn.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:

Expand|Select|Wrap|Line Numbers
  1. Warning: odbc_exec(): SQL error: [Microsoft][ODBC dBase
  2. Driver]
  3. The Microsoft Jet database engine could not find the object
  4. 'ADST.DBF'. Make sure the object exists and that you spell its name
  5. and the path name correctly., SQL state S0002 in SQLExecDirect in E:
  6. \InetPub\wwwroot\posa_test\includes\functions.inc on line
  7. 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.
Expand|Select|Wrap|Line Numbers
  1. //$connection_string = 'DRIVER={Microsoft dBase Driver
  2. (*.dbf)};SERVER=<10.112.139.230>;DATABASE=<ADST.DBF>';
  3. //$connection_string = 'DRIVER={Microsoft dBase Driver
  4. (*.dbf)};SERVER=<10.112.139.230>;DATABASE=<SASIxp>';
  5. //$connection_string = 'DRIVER={Microsoft dBase Driver
  6. (*.dbf)};datasource=SASIxp;';
  7. $connection_string = 'DRIVER={Microsoft dBase Driver (*.dbf)};
  8. datasource=\\\\sasi_main\\sasixp\\datafile\\ADST.DBF;';
  9. $user = '';
  10. $pass = '';
  11. //$connection = odbc_connect( $connection_string, $user, $pass );
  12. $odbc = odbc_connect ($connection_string, '', '') or die('Could Not
  13. Connect to ODBC Database!');
  14. $strsql= 'SELECT * FROM ADST.DBF';
  15. $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.
Jan 15 '08 #2

P: n/a

"Richard" <root@localhostwrote in message
news:47***********************@news.euronet.nl...
>
<bc*****@gmail.comwrote in message
news:24**********************************@u10g2000 prn.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:

Expand|Select|Wrap|Line Numbers
  1. Warning: odbc_exec(): SQL error: [Microsoft][ODBC dBase
  2. Driver]
  3. The Microsoft Jet database engine could not find the object
  4. 'ADST.DBF'. Make sure the object exists and that you spell its name
  5. and the path name correctly., SQL state S0002 in SQLExecDirect in
  6. E:
  7. \InetPub\wwwroot\posa_test\includes\functions.inc on line
  8. 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.
Expand|Select|Wrap|Line Numbers
  1. //$connection_string = 'DRIVER={Microsoft dBase Driver
  2. (*.dbf)};SERVER=<10.112.139.230>;DATABASE=<ADST.DBF>';
  3. //$connection_string = 'DRIVER={Microsoft dBase Driver
  4. (*.dbf)};SERVER=<10.112.139.230>;DATABASE=<SASIxp>';
  5. //$connection_string = 'DRIVER={Microsoft dBase Driver
  6. (*.dbf)};datasource=SASIxp;';
  7. $connection_string = 'DRIVER={Microsoft dBase Driver (*.dbf)};
  8. datasource=\\\\sasi_main\\sasixp\\datafile\\ADST.DBF;';
  9. $user = '';
  10. $pass = '';
  11. //$connection = odbc_connect( $connection_string, $user, $pass );
  12. $odbc = odbc_connect ($connection_string, '', '') or die('Could Not
  13. Connect to ODBC Database!');
  14. $strsql= 'SELECT * FROM ADST.DBF';
  15. $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.
Jan 15 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.