[Mono-list] Accessing Property ParameterName in Class SqlParameter

Daniel Morgan danmorg@sc.rr.com
Wed, 21 Aug 2002 02:35:27 -0400


Rodrigo,

I am having a problem accessing the property ParameterName for class
SqlParameter.
It works in Microsoft .NET, but not in Mono::.  I am using release 0.13
mono/mcs binaries.
I get the following message:

$ monomcs Parm.cs -r System.Data.dll
Parm.cs(39) error CS0154: indexer can not be used in this context, because
it la
cks a `get' accessor
Compilation failed: 1 error(s), 0 warnings

This is the line that has the compile error:
theParmName = prm.ParameterName; // get compiler error here

Here is the code I'm using to test it:

			IDbCommand cmd = new SqlCommand();
			string theParmName;

			int p;
			for(p = 0; p < 5; p++) {
				theParmName = p.ToString();
				IDataParameter prm = cmd.CreateParameter();
				prm.ParameterName = theParmName;
				prm.Direction = ParameterDirection.Input;
				prm.DbType = DbType.String; // default
				IList list = cmd.Parameters;
				list.Add(prm);
				Console.WriteLine("Parameter: " + theParmName + " added.");

			}
			Console.WriteLine("List parameters...");
			IDataParameterCollection parms = (IDataParameterCollection)
cmd.Parameters;
			for(p = 0; p < cmd.Parameters.Count; p++) {
				IDataParameter prm = (IDataParameter) parms[p];
				theParmName = prm.ParameterName; // get compiler error here
				Console.WriteLine("Parameter " + p.ToString() + ": " +
					theParmName);
			}

This is SqlParameter.cs:
		public string ParameterName {
			get {
				return parmName;
			}

			set {
				parmName = value;
			}
		}

I thought maybe ParameterName needs to be explictly defined
for interface IDataParameter, so I added:
		string IDataParameter.ParameterName {
			get {
				return ParameterName;
			}

			set {
				ParameterName = value;
			}
		}

But that didn't work either.

This is what is in IDataParameter.cs:
		string ParameterName{get;set;}

What am I doing wrong?

Thanks,
Daniel