3 // Permission is hereby granted, free of charge, to any person obtaining
4 // a copy of this software and associated documentation files (the
5 // "Software"), to deal in the Software without restriction, including
6 // without limitation the rights to use, copy, modify, merge, publish,
7 // distribute, sublicense, and/or sell copies of the Software, and to
8 // permit persons to whom the Software is furnished to do so, subject to
9 // the following conditions:
11 // The above copyright notice and this permission notice shall be
12 // included in all copies or substantial portions of the Software.
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 using System.Collections;
\r
25 using System.Globalization;
\r
28 namespace IBM.Data.DB2
\r
31 public class DB2ParameterCollection : ArrayList, IDataParameterCollection
\r
33 IntPtr hwndStmt = IntPtr.Zero;
\r
35 internal IntPtr HwndStmt
\r
42 public new DB2Parameter this[int index]
\r
46 return (DB2Parameter)base[index];
\r
50 base[index] = value;
\r
53 public DB2Parameter this[string index]
\r
57 return (DB2Parameter)base[IndexOf(index)];
\r
61 base[IndexOf(index)] = value;
\r
64 object IDataParameterCollection.this[string index]
\r
68 return this[IndexOf(index)];
\r
72 this[IndexOf(index)] = (DB2Parameter)value;
\r
75 public bool Contains(string paramName)
\r
77 return(-1 != IndexOf(paramName));
\r
80 public int IndexOf(string paramName)
\r
83 for(index = 0; index < Count; index++)
\r
85 if (0 == _cultureAwareCompare(((DB2Parameter)this[index]).ParameterName, paramName))
\r
93 public void RemoveAt(string paramName)
\r
95 RemoveAt(IndexOf(paramName));
\r
98 public override int Add(object obj)
\r
100 DB2Parameter value = (DB2Parameter)obj;
\r
101 if(value.ParameterName == null)
\r
102 throw new ArgumentException("parameter must be named");
\r
103 if(IndexOf(value.ParameterName) >= 0)
\r
104 throw new ArgumentException("parameter name is already in collection");
\r
105 return base.Add(value);
\r
108 public DB2Parameter Add(DB2Parameter value)
\r
110 if(value.ParameterName == null)
\r
111 throw new ArgumentException("parameter must be named");
\r
112 if(IndexOf(value.ParameterName) >= 0)
\r
113 throw new ArgumentException("parameter name is already in collection");
\r
118 public DB2Parameter Add(string paramName, DB2Type type)
\r
120 return Add(new DB2Parameter(paramName, type));
\r
123 public DB2Parameter Add(string paramName, object value)
\r
125 return Add(new DB2Parameter(paramName, value));
\r
128 public DB2Parameter Add(string paramName, DB2Type dbType, int size)
\r
130 return Add(new DB2Parameter(paramName, dbType, size));
\r
133 public DB2Parameter Add(string paramName, DB2Type dbType, int size, string sourceColumn)
\r
135 return Add(new DB2Parameter(paramName, dbType, size, sourceColumn));
\r
138 private int _cultureAwareCompare(string strA, string strB)
\r
140 return CultureInfo.CurrentCulture.CompareInfo.Compare(strA, strB, CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase);
\r
143 internal void GetOutValues()
\r
145 foreach(DB2Parameter param in this)
\r
147 if(ParameterDirection.Output == param.Direction || ParameterDirection.InputOutput == param.Direction)
\r
149 param.GetOutValue();
\r
150 //Console.WriteLine(param.ParameterName);
\r