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(@"s elect flag from
\\fileserver\i\ probill\act_fra u.DBF where act = '" + act.Trim() + "'",
myOdbcConnectio n);
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****@microsof t.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.nos pam>
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.Collecti ons;
using System.Componen tModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Serv ices;
using System.Web.Serv ices.Protocols;
using System.Xml.Linq ;
using System.Data.Odb c;
namespace CWebService1
{
/// <summary>
/// Summary description for Service1
/// </summary>
[WebService(Name space = "http://tempuri.org/")]
[WebServiceBindi ng(ConformsTo = WsiProfiles.Bas icProfile1_1)]
[ToolboxItem(fal se)]
// To allow this Web Service to be called from script, using
ASP.NET AJAX, uncomment the following line.
// [System.Web.Scri pt.Services.Scr iptService]
public class Service1 : System.Web.Serv ices.WebService
{
[WebMethod()]
public string CashOnly(string act)
{
DataSet ds = new DataSet();
OdbcConnection myOdbcConnectio n = new
OdbcConnection ("Driver={Micro soft Visual FoxPro Driver};"
+ "SourceType=DBF ;"
+ "SourceDB=c :;"
+ "Exclusive= No;"
+ "Collate=Machin e;"
+ "NULL=NO;"
+ "DELETED=NO ;"
+ "BACKGROUNDFETC H=NO");
OdbcCommand myOdbcCommand = new OdbcCommand("se lect flag
from d:\\act_frau.DB F where act = '" + act.Trim() + "'", myOdbcConnectio n);
myOdbcConnectio n.Open();
string results = myOdbcCommand.E xecuteScalar(). ToString();
myOdbcConnectio n.Close();
return results;
}
}
}
But with the actual production file on the network it doesn't:
OdbcCommand myOdbcCommand = new OdbcCommand("se lect flag
from \\\\fileserver\ \i\\probill\\ac t_frau.DBF where act = '" +
act.Trim() + "'", myOdbcConnectio n);
It gives me:
System.Data.Od bc.OdbcExceptio n: 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("se lect flag from
\\fileserver\i \probill\act_fr au.dbf where act = '" + act.Trim + "'",
myOdbcConnecti on)
What am I doing wrong?