Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
VFP OLE-DB provider, Stored Procedures, and C#
Message
De
26/08/2001 15:45:27
Nancy Folsom
Pixel Dust Industries
Washington, États-Unis
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Visual FoxPro et .NET
Titre:
VFP OLE-DB provider, Stored Procedures, and C#
Divers
Thread ID:
00549274
Message ID:
00549274
Vues:
65
So far I'm having a spectacular lack of success calling VFP OLE-DB stored procs that operate on tables from C#. For example, I've tried a stored procedure that PACKs a table or deletes one record. I've tried just an empty stored procedure. I'm starting to suspect something's broken in the OLE-DB provider.

I've tried a number of variations of setting the command text. The only success I had was calling a simple stored proc using the ExecuteReader command, which is not what I'm trying to achieve. Here is my C# code. The error returned in the try/catch block below is "Unrecognized command verb."
using System;
using System.Data;
using System.Data.OleDb;

namespace TestData
{
	/// <summary>
	/// Summary description for TestData.
	/// </summary>
	public class TestData
	{
		public TestData()
		{

			// string myConnString = "Provider=VFPOLEDB.1;Data Source=C:\\Temp\\Data\\TasTrade.DBC;Mode=Share De" +
			//		"ny None;Extended Properties=\"\";User ID=\"\";Password=\"\";Mask Password=False;Cache " +
			//		"Authentication=False;Encrypt Password=False;Collating Sequence=MACHINE";

			string myConnString = "Provider=VFPOLEDB.1;Data Source=C:\\TEMP\\DATA\\TASTRADE.DBC;Mode=Share Deny None;" +
				"Extended Properties=\"\";User ID=\"\";Password=\"\";Mask Password=False;" +
				"Cache Authentication=False;Encrypt Password=False;Collating Sequence=MACHINE";
			
			OleDbConnection myConnection = new OleDbConnection(myConnString);

			string myCmd;
			myCmd = "DeleteOrder" ; // Stored procedure that just deletes one record with  DELETE - SQL command
			
			OleDbCommand myCommand = new OleDbCommand(myCmd,myConnection);

			myConnection.Open();

			int cmdResults = -1 ;
			
			myCommand.CommandType = CommandType.StoredProcedure ;

			try
			{
				cmdResults = myCommand.ExecuteNonQuery(); // NonQuery since no SQL rows are returned
				
			} 
			catch(System.Data.OleDb.OleDbException e) 
			{
				Console.WriteLine("Error occured: " + e.Message);
			}
			finally
			{			
				myConnection.Close();
				Console.WriteLine("cmdResults " + cmdResults);
				Console.ReadLine();
			}
		}
		public static void Main()
		{
			TestData foo = new TestData();
		}
	}
}
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform