Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP OLE-DB provider, Stored Procedures, and C#
Message
 
 
To
26/08/2001 15:45:27
General information
Forum:
Visual FoxPro
Category:
Visual FoxPro and .NET
Miscellaneous
Thread ID:
00549274
Message ID:
00549283
Views:
16
Hi Nancy,
Try CommandType.CmdText (or however it called in C#) instead of CommandType.StoredProcedure.

>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();
>		}
>	}
>}
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform