2002-10-25 Tim Coleman (tim@timcoleman.com)
[mono.git] / mcs / class / System.Data / System.Data.SqlClient / SqlParameter.cs
1 //
2 // System.Data.SqlClient.SqlParameter.cs
3 //
4 // Author:
5 //   Rodrigo Moya (rodrigo@ximian.com)
6 //   Daniel Morgan (danmorg@sc.rr.com)
7 //   Tim Coleman (tim@timcoleman.com)
8 //
9 // (C) Ximian, Inc. 2002
10 // Copyright (C) Tim Coleman, 2002
11 //
12 using System;
13 using System.ComponentModel;
14 using System.Data;
15 using System.Data.Common;
16 using System.Runtime.InteropServices;
17
18 namespace System.Data.SqlClient {
19         /// <summary>
20         /// Represents a parameter to a Command object, and optionally, 
21         /// its mapping to DataSet columns; and is implemented by .NET 
22         /// data providers that access data sources.
23         /// </summary>
24         public sealed class SqlParameter : MarshalByRefObject, IDbDataParameter, IDataParameter, ICloneable
25         {
26
27                 #region Fields
28
29                 string parmName;
30                 SqlDbType dbtype;
31                 DbType theDbType;
32                 object objValue;
33                 int size;
34                 string sourceColumn;
35                 ParameterDirection direction;
36                 bool isNullable;
37                 byte precision;
38                 byte scale;
39                 DataRowVersion sourceVersion;
40                 int offset;
41
42                 #endregion // Fields
43
44                 #region Constructors
45
46                 [MonoTODO]
47                 public SqlParameter () 
48                 {
49                 }
50
51                 [MonoTODO]
52                 public SqlParameter (string parameterName, object value) 
53                 {
54                         this.parmName = parameterName;
55                         this.objValue = value;
56                 }
57                 
58                 [MonoTODO]
59                 public SqlParameter (string parameterName, SqlDbType dbType) 
60                 {
61                         this.parmName = parameterName;
62                         this.dbtype = dbType;
63                 }
64
65                 [MonoTODO]
66                 public SqlParameter (string parameterName, SqlDbType dbType, int size) 
67                 {
68
69                         this.parmName = parameterName;
70                         this.dbtype = dbType;
71                         this.size = size;
72                 }
73                 
74                 [MonoTODO]
75                 public SqlParameter(string parameterName, SqlDbType dbType, int size, string sourceColumn) 
76                 {
77
78                         this.parmName = parameterName;
79                         this.dbtype = dbType;
80                         this.size = size;
81                         this.sourceColumn = sourceColumn;
82                 }
83                          
84                 [MonoTODO]
85                 public SqlParameter(string parameterName, SqlDbType dbType, int size, ParameterDirection direction, bool isNullable, byte precision, byte scale, string sourceColumn, DataRowVersion sourceVersion, object value) 
86                 {
87                         
88                         this.parmName = parameterName;
89                         this.dbtype = dbType;
90                         this.size = size;
91                         this.sourceColumn = sourceColumn;
92                         this.direction = direction;
93                         this.isNullable = isNullable;
94                         this.precision = precision;
95                         this.scale = scale;
96                         this.sourceVersion = sourceVersion;
97                         this.objValue = value;
98                 }
99
100                 #endregion // Constructors
101
102                 #region Properties
103
104                 [MonoTODO]
105                 public DbType DbType {
106                         get { return theDbType; }
107                         set { theDbType = value; }
108                 }
109
110                 [MonoTODO]
111                 public ParameterDirection Direction {
112                         get { return direction; }
113                         set { direction = value; }
114                 }
115
116                 [MonoTODO]
117                 public bool IsNullable  {
118                         get { return isNullable; }
119                 }
120
121                 [MonoTODO]
122                 public int Offset {
123                         get { return offset; }
124                         set { offset = value; }
125                 }
126
127                 
128                 string IDataParameter.ParameterName {
129                         get { return parmName; }
130                         set { parmName = value; }
131                 }
132                 
133                 public string ParameterName {
134                         get { return parmName; }
135                         set { parmName = value; }
136                 }
137
138                 [MonoTODO]
139                 public string SourceColumn {
140                         get { return sourceColumn; }
141                         set { sourceColumn = value; }
142                 }
143
144                 [MonoTODO]
145                 public DataRowVersion SourceVersion {
146                         get { return sourceVersion; }
147                         set { sourceVersion = value; }
148                 }
149                 
150                 [MonoTODO]
151                 public SqlDbType SqlDbType {
152                         get { return dbtype; }
153                         set { dbtype = value; }
154                 }
155
156                 [MonoTODO]
157                 public object Value {
158                         get { return objValue; }
159                         set { objValue = value; }
160                 }
161
162                 [MonoTODO]
163                 public byte Precision {
164                         get { return precision; }
165                         set { precision = value; }
166                 }
167
168                 [MonoTODO]
169                 public byte Scale {
170                         get { return scale; }
171                         set { scale = value; }
172                 }
173
174                 [MonoTODO]
175                 public int Size {
176                         get { return size; }
177                         set { size = value; }
178                 }
179
180                 #endregion // Properties
181
182                 #region Methods
183
184                 [MonoTODO]
185                 object ICloneable.Clone ()
186                 {
187                         throw new NotImplementedException ();
188                 }
189
190                 public override string ToString() 
191                 {
192                         return parmName;
193                 }
194
195                 #endregion // Methods
196         }
197 }