3 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
5 // Permission is hereby granted, free of charge, to any person obtaining
6 // a copy of this software and associated documentation files (the
7 // "Software"), to deal in the Software without restriction, including
8 // without limitation the rights to use, copy, modify, merge, publish,
9 // distribute, sublicense, and/or sell copies of the Software, and to
10 // permit persons to whom the Software is furnished to do so, subject to
11 // the following conditions:
13 // The above copyright notice and this permission notice shall be
14 // included in all copies or substantial portions of the Software.
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 namespace System.Data.Odbc
29 /// Summary description for OdbcColumn.
31 internal class OdbcColumn
33 internal string ColumnName;
34 internal OdbcType OdbcType;
35 private SQL_TYPE _sqlType = SQL_TYPE.UNASSIGNED;
36 private SQL_C_TYPE _sqlCType = SQL_C_TYPE.UNASSIGNED;
37 internal bool AllowDBNull;
38 internal int MaxLength;
40 internal object Value;
42 internal OdbcColumn (string Name, OdbcType Type)
44 this.ColumnName = Name;
52 internal OdbcColumn (string Name, SQL_TYPE type)
54 this.ColumnName = Name;
64 internal Type DataType
70 case OdbcType.TinyInt:
71 return typeof (System.Byte);
73 return typeof (System.Int64);
75 case OdbcType.VarBinary:
77 return typeof (byte[]);
82 return typeof (string);
84 case OdbcType.Timestamp:
85 case OdbcType.DateTime:
87 case OdbcType.SmallDateTime:
88 return typeof (DateTime);
89 case OdbcType.Decimal:
90 return typeof (Decimal);
91 case OdbcType.Numeric:
93 return typeof (Double);
95 return typeof (System.Int32);
98 case OdbcType.NVarChar:
99 case OdbcType.VarChar:
100 return typeof (string);
102 return typeof (float);
103 case OdbcType.SmallInt:
104 return typeof (System.Int16);
105 case OdbcType.UniqueIdentifier:
106 return typeof (Guid);
108 throw new InvalidCastException();
112 internal bool IsDateType
119 case OdbcType.Timestamp:
120 case OdbcType.DateTime:
122 case OdbcType.SmallDateTime:
130 internal bool IsStringType
139 case OdbcType.NVarChar:
140 case OdbcType.VarChar:
148 internal bool IsVariableSizeType {
153 case OdbcType.Binary :
154 case OdbcType.VarBinary :
155 case OdbcType.Image :
163 internal SQL_TYPE SqlType
166 if ( _sqlType == SQL_TYPE.UNASSIGNED)
167 _sqlType = OdbcTypeConverter.GetTypeMap (OdbcType).SqlType;
171 set {_sqlType = value;}
174 internal SQL_C_TYPE SqlCType
178 if ( _sqlCType == SQL_C_TYPE.UNASSIGNED)
179 _sqlCType = OdbcTypeConverter.GetTypeMap (OdbcType).NativeType;
182 set {_sqlCType = value;}
185 internal void UpdateTypes (SQL_TYPE sqlType)
188 OdbcTypeMap map = OdbcTypeConverter.GetTypeMap (SqlType);
189 OdbcType = map.OdbcType;
190 SqlCType = map.NativeType;