Exception when accesing remotely VFP by using ODBC .NET provider.

  • Thread starter Jean-Francois Hamelin
  • Start date
J

Jean-Francois Hamelin

Hi,

I have a web service that tries to fetch data from a Visual FoxPro database
sitting on a remote PC. The database is accessible by a file share with
everyone set to full control.

IIS and ASP.NET authentication are set to use windows integrated and
impersonate is true.

I can open the connection to the database, but I received an exception when
accessing the tables. The exception is

{@"ERROR [S1000] [Microsoft][ODBC Visual FoxPro Driver]Cannot open file
\\remotePC\database\MyTable.dbf." }

This is the code:

[WebMethod]
public void HelloWorld()
{
OdbcConnection con = new OdbcConnection( "DSN=MyDSN" );
OdbcCommand myCommand = new OdbcCommand( "SELECT * FROM MyTable", con );
con.Open();
try
{
OdbcDataReader myReader = myCommand.ExecuteReader();
while( myReader.Read() )
{}
}
catch( Exception exception )
{
string ex = exception.Message;
// ex = {@"ERROR [S1000] [Microsoft][ODBC Visual FoxPro
Driver]Cannot open file \\remotePC\database\MyTable.dbf." }
}
}

Same code, same database, same table, and same DSN in a console application
does not generate an exception.

Any ideas why it does not work ?

Thanks
JF
 
J

Jean-Francois Hamelin

Yes we have consider to use OLE DB, but right now we are migrating an MFC
C++ application that uses VFP database to C# an in order to ease the first
generation of updates we have decide to keep the DSN configuration of the
customer. Eventually we will migration to OLE DB.

What also stop us from directly going to OLE DB is it does not support DSN
even if in the connection string there is an entry for it, can you confirm
this? I will perform a small test and post back the exception message.

I did ensure that all the drivers are the same version on the client and
server machine.

JF

Cindy Winegarden said:
Hi Jean-Francois,

It's probably not central to your problem, but have you considered using the
Visual FoxPro OLE DB data provider? It's downloadable from
http://msdn.microsoft.com/vfoxpro/downloads/updates.

Also, does it help to install the drivers on both the remote machine where
the data is, and the server?

--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
(e-mail address removed) www.cindywinegarden.com


Jean-Francois Hamelin said:
Hi,

I have a web service that tries to fetch data from a Visual FoxPro
database
sitting on a remote PC. The database is accessible by a file share with
everyone set to full control.

IIS and ASP.NET authentication are set to use windows integrated and
impersonate is true.

I can open the connection to the database, but I received an exception
when
accessing the tables. The exception is

{@"ERROR [S1000] [Microsoft][ODBC Visual FoxPro Driver]Cannot open file
\\remotePC\database\MyTable.dbf." }

This is the code:

[WebMethod]
public void HelloWorld()
{
OdbcConnection con = new OdbcConnection( "DSN=MyDSN" );
OdbcCommand myCommand = new OdbcCommand( "SELECT * FROM MyTable",
con );
con.Open();
try
{
OdbcDataReader myReader = myCommand.ExecuteReader();
while( myReader.Read() )
{}
}
catch( Exception exception )
{
string ex = exception.Message;
// ex = {@"ERROR [S1000] [Microsoft][ODBC Visual FoxPro
Driver]Cannot open file \\remotePC\database\MyTable.dbf." }
}
}

Same code, same database, same table, and same DSN in a console
application
does not generate an exception.

Any ideas why it does not work ?

Thanks
JF
 
J

Jean-Francois Hamelin

This code generate an exception on the .Open() with message 'Invalid path or
file name.'

Again the same code running in a console application works perfectly.

[WebMethod]
public string HelloWorld()
{
try
{
OleDbConnection con = new OleDbConnection(
"DSN='MyDSN';Provider='VFPOLEDB.1'" );
OleDbCommand myCommand = new OleDbCommand( "SELECT * FROM MyTable",
con );
con.Open();

OleDbDataReader myReader = myCommand.ExecuteReader();
while( myReader.Read() )
{}
return "Hello World";
}
catch( Exception exception )
{
return exception.Message ;
}
}

Jean-Francois Hamelin said:
Yes we have consider to use OLE DB, but right now we are migrating an MFC
C++ application that uses VFP database to C# an in order to ease the first
generation of updates we have decide to keep the DSN configuration of the
customer. Eventually we will migration to OLE DB.

What also stop us from directly going to OLE DB is it does not support DSN
even if in the connection string there is an entry for it, can you confirm
this? I will perform a small test and post back the exception message.

I did ensure that all the drivers are the same version on the client and
server machine.

JF

Cindy Winegarden said:
Hi Jean-Francois,

It's probably not central to your problem, but have you considered using the
Visual FoxPro OLE DB data provider? It's downloadable from
http://msdn.microsoft.com/vfoxpro/downloads/updates.

Also, does it help to install the drivers on both the remote machine where
the data is, and the server?

--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
(e-mail address removed) www.cindywinegarden.com


message news:[email protected]...
Hi,

I have a web service that tries to fetch data from a Visual FoxPro
database
sitting on a remote PC. The database is accessible by a file share with
everyone set to full control.

IIS and ASP.NET authentication are set to use windows integrated and
impersonate is true.

I can open the connection to the database, but I received an exception
when
accessing the tables. The exception is

{@"ERROR [S1000] [Microsoft][ODBC Visual FoxPro Driver]Cannot open file
\\remotePC\database\MyTable.dbf." }

This is the code:

[WebMethod]
public void HelloWorld()
{
OdbcConnection con = new OdbcConnection( "DSN=MyDSN" );
OdbcCommand myCommand = new OdbcCommand( "SELECT * FROM MyTable",
con );
con.Open();
try
{
OdbcDataReader myReader = myCommand.ExecuteReader();
while( myReader.Read() )
{}
}
catch( Exception exception )
{
string ex = exception.Message;
// ex = {@"ERROR [S1000] [Microsoft][ODBC Visual FoxPro
Driver]Cannot open file \\remotePC\database\MyTable.dbf." }
}
}

Same code, same database, same table, and same DSN in a console
application
does not generate an exception.

Any ideas why it does not work ?

Thanks
JF
 
J

Jean-Francois Hamelin

Forget about the last post about OLE DB and DSN it works ok. I was missing
impresonate=true in my web.config file.


Jean-Francois Hamelin said:
This code generate an exception on the .Open() with message 'Invalid path or
file name.'

Again the same code running in a console application works perfectly.

[WebMethod]
public string HelloWorld()
{
try
{
OleDbConnection con = new OleDbConnection(
"DSN='MyDSN';Provider='VFPOLEDB.1'" );
OleDbCommand myCommand = new OleDbCommand( "SELECT * FROM MyTable",
con );
con.Open();

OleDbDataReader myReader = myCommand.ExecuteReader();
while( myReader.Read() )
{}
return "Hello World";
}
catch( Exception exception )
{
return exception.Message ;
}
}

Jean-Francois Hamelin said:
Yes we have consider to use OLE DB, but right now we are migrating an MFC
C++ application that uses VFP database to C# an in order to ease the first
generation of updates we have decide to keep the DSN configuration of the
customer. Eventually we will migration to OLE DB.

What also stop us from directly going to OLE DB is it does not support DSN
even if in the connection string there is an entry for it, can you confirm
this? I will perform a small test and post back the exception message.

I did ensure that all the drivers are the same version on the client and
server machine.

JF

Cindy Winegarden said:
Hi Jean-Francois,

It's probably not central to your problem, but have you considered
using
the
Visual FoxPro OLE DB data provider? It's downloadable from
http://msdn.microsoft.com/vfoxpro/downloads/updates.

Also, does it help to install the drivers on both the remote machine where
the data is, and the server?

--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
(e-mail address removed) www.cindywinegarden.com


message Hi,

I have a web service that tries to fetch data from a Visual FoxPro
database
sitting on a remote PC. The database is accessible by a file share with
everyone set to full control.

IIS and ASP.NET authentication are set to use windows integrated and
impersonate is true.

I can open the connection to the database, but I received an exception
when
accessing the tables. The exception is

{@"ERROR [S1000] [Microsoft][ODBC Visual FoxPro Driver]Cannot open file
\\remotePC\database\MyTable.dbf." }

This is the code:

[WebMethod]
public void HelloWorld()
{
OdbcConnection con = new OdbcConnection( "DSN=MyDSN" );
OdbcCommand myCommand = new OdbcCommand( "SELECT * FROM MyTable",
con );
con.Open();
try
{
OdbcDataReader myReader = myCommand.ExecuteReader();
while( myReader.Read() )
{}
}
catch( Exception exception )
{
string ex = exception.Message;
// ex = {@"ERROR [S1000] [Microsoft][ODBC Visual FoxPro
Driver]Cannot open file \\remotePC\database\MyTable.dbf." }
}
}

Same code, same database, same table, and same DSN in a console
application
does not generate an exception.

Any ideas why it does not work ?

Thanks
JF
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top