1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
|
//------------------------------------------------------------------------------
// <copyright file="OdbcParameterCollection.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
// <owner current="true" primary="true">Microsoft</owner>
// <owner current="true" primary="false">Microsoft</owner>
//------------------------------------------------------------------------------
namespace System.Data.Odbc {
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.Common;
using System.Data.ProviderBase;
using System.Diagnostics;
using System.Runtime.InteropServices;
[
Editor("Microsoft.VSDesigner.Data.Design.DBParametersEditor, " + AssemblyRef.MicrosoftVSDesigner, "System.Drawing.Design.UITypeEditor, " + AssemblyRef.SystemDrawing),
ListBindable(false)
]
public sealed partial class OdbcParameterCollection : DbParameterCollection {
private bool _rebindCollection; // The collection needs to be (re)bound
private static Type ItemType = typeof(OdbcParameter);
internal OdbcParameterCollection() : base() {
}
internal bool RebindCollection {
get { return _rebindCollection; }
set { _rebindCollection = value; }
}
[
Browsable(false),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)
]
new public OdbcParameter this[int index] {
get {
return (OdbcParameter)GetParameter(index);
}
set {
SetParameter(index, value);
}
}
[
Browsable(false),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)
]
new public OdbcParameter this[string parameterName] {
get {
return (OdbcParameter)GetParameter(parameterName);
}
set {
SetParameter(parameterName, value);
}
}
public OdbcParameter Add(OdbcParameter value) {
// MDAC 59206
Add((object)value);
return value;
}
[ EditorBrowsableAttribute(EditorBrowsableState.Never)]
[ ObsoleteAttribute("Add(String parameterName, Object value) has been deprecated. Use AddWithValue(String parameterName, Object value). http://go.microsoft.com/fwlink/?linkid=14202", false) ] // 79027
public OdbcParameter Add(string parameterName, object value) {
// MDAC 59206
return Add(new OdbcParameter(parameterName, value));
}
public OdbcParameter AddWithValue(string parameterName, object value) {
// MDAC 79027
return Add(new OdbcParameter(parameterName, value));
}
public OdbcParameter Add(string parameterName, OdbcType odbcType) {
return Add(new OdbcParameter(parameterName, odbcType));
}
public OdbcParameter Add(string parameterName, OdbcType odbcType, int size) {
return Add(new OdbcParameter(parameterName, odbcType, size));
}
public OdbcParameter Add(string parameterName, OdbcType odbcType, int size, string sourceColumn) {
return Add(new OdbcParameter(parameterName, odbcType, size, sourceColumn));
}
public void AddRange(OdbcParameter[] values) {
// V1.2.3300
AddRange((Array)values);
}
// Walks through the collection and binds each parameter
//
internal void Bind(OdbcCommand command, CMDWrapper cmdWrapper, CNativeBuffer parameterBuffer){
for(int i = 0; i < Count; ++i) {
this[i].Bind(cmdWrapper.StatementHandle, command, checked((short)(i+1)), parameterBuffer, true);
}
_rebindCollection = false;
}
internal int CalcParameterBufferSize(OdbcCommand command){
// Calculate the size of the buffer we need
int parameterBufferSize = 0;
for(int i = 0; i < Count; ++i) {
if (_rebindCollection) {
this[i].HasChanged = true;
}
this[i].PrepareForBind(command, (short)(i+1), ref parameterBufferSize);
parameterBufferSize = (parameterBufferSize + (IntPtr.Size-1)) & ~(IntPtr.Size-1); // align buffer;
}
return parameterBufferSize;
}
// Walks through the collection and clears the parameters
//
internal void ClearBindings () {
for(int i = 0; i < Count; ++i) {
this[i].ClearBinding();
}
}
override public bool Contains(string value) { // WebData 97349
return (-1 != IndexOf(value));
}
public bool Contains(OdbcParameter value) {
return (-1 != IndexOf(value));
}
public void CopyTo(OdbcParameter[] array, int index) {
CopyTo((Array)array, index);
}
private void OnChange() {
_rebindCollection = true;
}
internal void GetOutputValues (CMDWrapper cmdWrapper) {
// mdac 88542 - we will not read out the parameters if the collection has changed
if (!_rebindCollection) {
CNativeBuffer parameterBuffer = cmdWrapper._nativeParameterBuffer;
for(int i = 0; i < Count; ++i) {
this[i].GetOutputValue(parameterBuffer);
}
}
}
public int IndexOf(OdbcParameter value) {
return IndexOf((object)value);
}
public void Insert(int index, OdbcParameter value) {
Insert(index, (object)value);
}
public void Remove(OdbcParameter value) {
Remove((object)value);
}
}
}
|