I have installed the VFP OleDB Provider and I can access a free DBF table after dragging the OleDbConnection and OleDbDataAdapter objects onto my C# WebService project design pannel and generate a DataSet.
However, I cannot access the free table via a DataReader object.
My WebService has the following code:
[WebMethod]
public string GetLastPrefix()
{
string sqlString;
string lastPrefix;
OleDbCommand sqlCmd = new OleDbCommand();
sqlString = "SELECT cPrefix FROM bsreg";
sqlCmd.CommandType = CommandType.Text;
sqlCmd.CommandText = sqlString;
sqlCmd.Connection = xOleDbConn;
// Init lastPrefix to ""
lastPrefix = "";
xOleDbConn.Open();
OleDbDataReader dr = sqlCmd.ExecuteReader();
if (dr.Read())
lastPrefix = dr[0].ToString();
xOleDbConn.Close();
return lastPrefix;
}
And I get the following error when I invoke the WebService:
System.InvalidOperationException: The 'VFPOLEDB.1' provider is not registered on the local machine. ---> System.Data.OleDb.OleDbException: No error information available: REGDB_E_CLASSNOTREG(0x80040154).
--- End of inner exception stack trace ---
at System.Data.OleDb.OleDbConnection.CreateProviderError(Int32 hr)
at System.Data.OleDb.OleDbConnection.CreateProvider()
at System.Data.OleDb.OleDbConnection.Open()
at wsBSSN.BSSN.GetLastPrefix() in d:\develop\net\bssn\wsbssn\bssn.asmx.cs:line 96
Line 96 points to: xOleDbConn.Open();
I'm not getting any compile errors.
Does the VFP OleDb Provider work with the DataReader object?
>You need to use the OLEDB provider that ships with VFP7 not ODBC. There are samples available about how to access VFP data using ADO.NET in the following whitepaper:
>
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnfoxgen7/html/usingaspnetwithvfp7.asp