Hi Cj,
From your description, you're trying to connect a VFP database in an
ASP.NET webservice, you used the ODBC driver. However, you found that the
code didn't work in webservice(from a network place) while worked for a
database file on local disk, correct?
I've also discussed this with some other database engineer. They suggest
you check the following things:
1.Make sure there hasn't any other program or person that has opened the
vfp database before your code accesss it. That'll possibly cause the
database not found error.
2. In the code, the only difference is the string escaping for the back
slash. I suggest you try using the following style code in C3 to see
whether it works:
OdbcCommand myOdbcCommand = new OdbcCommand(@"select flag from
\\fileserver\i\probill\act_frau.DBF where act = '" + act.Trim() + "'",
myOdbcConnection);
Btw, regarding on the network place, have you tried performing some other
simple remote resource accessing , such as try accessing a file via
System.IO API on that server to see whether you'll get similar error? If
so, that may indicate some network resource accessing issue.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>Date: Wed, 02 Jul 2008 10:42:06 -0400
From: cj2 <cj*@nospam.nospam>
User-Agent: Thunderbird 2.0.0.14 (Windows/20080421)
MIME-Version: 1.0
Subject: can't see this odbc datasource on the network from a web service
>
This code works:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using System.Data.Odbc;
namespace CWebService1
{
/// <summary>
/// Summary description for Service1
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
// To allow this Web Service to be called from script, using
ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class Service1 : System.Web.Services.WebService
{
[WebMethod()]
public string CashOnly(string act)
{
DataSet ds = new DataSet();
OdbcConnection myOdbcConnection = new
OdbcConnection("Driver={Microsoft Visual FoxPro Driver};"
+ "SourceType=DBF;"
+ "SourceDB=c:;"
+ "Exclusive=No;"
+ "Collate=Machine;"
+ "NULL=NO;"
+ "DELETED=NO;"
+ "BACKGROUNDFETCH=NO");
OdbcCommand myOdbcCommand = new OdbcCommand("select flag
from d:\\act_frau.DBF where act = '" + act.Trim() + "'", myOdbcConnection);
myOdbcConnection.Open();
string results = myOdbcCommand.ExecuteScalar().ToString();
myOdbcConnection.Close();
return results;
}
}
}
But with the actual production file on the network it doesn't:
OdbcCommand myOdbcCommand = new OdbcCommand("select flag
from \\\\fileserver\\i\\probill\\act_frau.DBF where act = '" +
act.Trim() + "'", myOdbcConnection);
It gives me:
System.Data.Odbc.OdbcException: ERROR [42S02] [Microsoft][ODBC Visual
FoxPro Driver]File 'act_frau.dbf' does not exist.
The file does exist. FYI, i is a directory not a drive letter.
I've also tried this web service in VB and it works:
Dim myOdbcCommand As New OdbcCommand("select flag from
\\fileserver\i\probill\act_frau.dbf where act = '" + act.Trim + "'",
myOdbcConnection)
What am I doing wrong?