Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFPOLEDB and Parameters
Message
From
30/06/2004 13:27:55
 
 
To
29/06/2004 16:09:10
General information
Forum:
ASP.NET
Category:
ADO.NET
Miscellaneous
Thread ID:
00918644
Message ID:
00919182
Views:
7
Hi, Dan-

>How do I use the parameter collection to pass parementers to commands?

I didn't read every single reply, but most. I don't see you've assigned a solution to any answer, so I'll post this. Hope I'm not repeating something someone else has done.

The following example should run as is (just to make sure we're on the same page). Sometimes it's a little simpler to have a running example, since where the problem is might not be exactly where one thinks. Ostensibly there doesn't seem to be anything wrong with your Parms statement (with the addition of the '@'). So, here's an example:
using System;
using System.Data;
using System.Data.OleDb;

namespace VFUG_From_xBASE_to_.NET
{
	public class OleDBExample
	{
		public OleDbDataReader DataReader;

		[STAThread]
		static void Main(string[] args)
		{
			OleDBExample ex = new OleDBExample();
			ex.GetCustomer("ALFKI");
			OleDbDataReader dr = ex.DataReader;
			if (dr.HasRows)
			{
				dr.Read();
				Console.WriteLine(dr.GetString(dr.GetOrdinal("companyname")));
			}
			else
				Console.WriteLine("No customers match.");
			Console.ReadLine();
			dr.Close();
		}
		public OleDBExample()
		{
		}
		public void GetCustomer(string CustomerID)
		{
			string mySelectQuery = "SELECT * FROM Customers where CustomerID = ?";
			
			string myConnString = "Provider=VFPOLEDB;" +
				"Data Source=C:\\PROGRAM FILES\\MICROSOFT VISUAL FOXPRO 8\\SAMPLES\\NORTHWIND\\NORTHWIND.DBC;" + 
				"Mode=Share Deny None;" +
				"Extended Properties=\"\";" +
				"User ID=\"\";Password=\"\";" + 
				"Mask Password=False;Cache " +
				"Authentication=False;" + 
				"Encrypt Password=False;" + 
				"Collating Sequence=MACHINE";

			OleDbCommand myCommand = new OleDbCommand();
			myCommand.CommandText = mySelectQuery;
			myCommand.Connection = new OleDbConnection();
			myCommand.Connection.ConnectionString = myConnString;
			myCommand.Parameters.Add("@CustomerID",CustomerID);
			myCommand.Connection.Open();
			DataReader = myCommand.ExecuteReader();
		}
	}
}
HTH.

p.s. my oledb provider is version 9.0.0.815 dated 2003/08/15, which should be the release version. If you've installed the 9.0 beta you might be using the beta OLEDB provider.
Previous
Reply
Map
View

Click here to load this message in the networking platform