C
cj2
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?
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?