Author: suresh
Date: 2005-03-10 04:13:45 -0500 (Thu, 10 Mar 2005)
New Revision: 41640
Added:
trunk/mcs/class/System.Data/System.Data.Odbc/OdbcTypeConverter.cs
Modified:
trunk/mcs/class/System.Data/ChangeLog
trunk/mcs/class/System.Data/System.Data.Odbc/ChangeLog
trunk/mcs/class/System.Data/System.Data.Odbc/OdbcColumn.cs
trunk/mcs/class/System.Data/System.Data.Odbc/OdbcDataReader.cs
trunk/mcs/class/System.Data/System.Data.Odbc/OdbcParameter.cs
trunk/mcs/class/System.Data/System.Data.Odbc/OdbcType.cs
trunk/mcs/class/System.Data/System.Data.Odbc/libodbc.cs
trunk/mcs/class/System.Data/System.Data.dll.sources
Log:
In .:
2005-03-10 Sureshkumar T <[EMAIL PROTECTED]>
* System.Data.dll.sources: Added
System.Data.Odbc/OdbcTypeConverter.
In System.Data.Odbc:
2005-03-10 Sureshkumar T <[EMAIL PROTECTED]>
* OdbcType.cs: Added enums for SQL_TYPE & SQL_C_TYPE.
* libodbc.cs: Accept SQL_C_TYPE for driver
parameters. SQLBindParameter takes two parameters SQL_TYPE and
SQL_C_TYPE. This caused the whole lot of changes done in this
revision.
* OdbcParameter.cs: Set default values of OdbcType & DbType. Pass
mapped SQL_TYPE and SQL_C_TYPE to SQLBindParameter. Increase
buffer size by 2 for additional ' chars.
* OdbcTypeConverter.cs: Added class to convert between OdbcType,
SQL_TYPE, SQL_C_TYPE.
* OdbcColumn.cs: Added private members for SQL_TYPE and
SQL_C_TYPE. conversion from/to odbctype to/from SQL_TYPE is done
through OdbcTypeConverter class.
* OdbcDataReader.cs: use OdbcColumn's SQL_C_TYPE member. It keeps
track of default mapping between odbctype, SQL_TYPE and
SQL_C_TYPE. Move dataTableSchema.AcceptChanges inside if condition
to avoid null reference exception.
Modified: trunk/mcs/class/System.Data/ChangeLog
===================================================================
--- trunk/mcs/class/System.Data/ChangeLog 2005-03-10 08:59:37 UTC (rev
41639)
+++ trunk/mcs/class/System.Data/ChangeLog 2005-03-10 09:13:45 UTC (rev
41640)
@@ -1,3 +1,8 @@
+2005-03-10 Sureshkumar T <[EMAIL PROTECTED]>
+
+ * System.Data.dll.sources: Added
+ System.Data.Odbc/OdbcTypeConverter.
+
2005-03-02 Sureshkumar T <[EMAIL PROTECTED]>
* System.Data.dll.sources: Added
Modified: trunk/mcs/class/System.Data/System.Data.Odbc/ChangeLog
===================================================================
--- trunk/mcs/class/System.Data/System.Data.Odbc/ChangeLog 2005-03-10
08:59:37 UTC (rev 41639)
+++ trunk/mcs/class/System.Data/System.Data.Odbc/ChangeLog 2005-03-10
09:13:45 UTC (rev 41640)
@@ -1,3 +1,28 @@
+2005-03-10 Sureshkumar T <[EMAIL PROTECTED]>
+
+ * OdbcType.cs: Added enums for SQL_TYPE & SQL_C_TYPE.
+
+ * libodbc.cs: Accept SQL_C_TYPE for driver
+ parameters. SQLBindParameter takes two parameters SQL_TYPE and
+ SQL_C_TYPE. This caused the whole lot of changes done in this
+ revision.
+
+ * OdbcParameter.cs: Set default values of OdbcType & DbType. Pass
+ mapped SQL_TYPE and SQL_C_TYPE to SQLBindParameter. Increase
+ buffer size by 2 for additional ' chars.
+
+ * OdbcTypeConverter.cs: Added class to convert between OdbcType,
+ SQL_TYPE, SQL_C_TYPE.
+
+ * OdbcColumn.cs: Added private members for SQL_TYPE and
+ SQL_C_TYPE. conversion from/to odbctype to/from SQL_TYPE is done
+ through OdbcTypeConverter class.
+
+ * OdbcDataReader.cs: use OdbcColumn's SQL_C_TYPE member. It keeps
+ track of default mapping between odbctype, SQL_TYPE and
+ SQL_C_TYPE. Move dataTableSchema.AcceptChanges inside if condition
+ to avoid null reference exception.
+
2005-02-04 Sureshkumar T <[EMAIL PROTECTED]>
Appasamy <[EMAIL PROTECTED]>
Modified: trunk/mcs/class/System.Data/System.Data.Odbc/OdbcColumn.cs
===================================================================
--- trunk/mcs/class/System.Data/System.Data.Odbc/OdbcColumn.cs 2005-03-10
08:59:37 UTC (rev 41639)
+++ trunk/mcs/class/System.Data/System.Data.Odbc/OdbcColumn.cs 2005-03-10
09:13:45 UTC (rev 41640)
@@ -32,6 +32,8 @@
{
internal string ColumnName;
internal OdbcType OdbcType;
+ private SQL_TYPE _sqlType = SQL_TYPE.UNASSIGNED;
+ private SQL_C_TYPE _sqlCType = SQL_C_TYPE.UNASSIGNED;
internal bool AllowDBNull;
internal int MaxLength;
internal int Digits;
@@ -46,6 +48,18 @@
Digits=0;
Value=null;
}
+
+ internal OdbcColumn(string Name, SQL_TYPE type)
+ {
+ this.ColumnName=Name;
+ AllowDBNull=false;
+ MaxLength=0;
+ Digits=0;
+ Value=null;
+ UpdateTypes (type);
+
+ }
+
internal Type DataType
{
@@ -129,6 +143,38 @@
}
}
}
+
+ internal SQL_TYPE SqlType
+ {
+ get {
+ if ( _sqlType == SQL_TYPE.UNASSIGNED)
+ _sqlType =
OdbcTypeConverter.ConvertToSqlType (OdbcType);
+ return _sqlType;
+ }
+
+ set {_sqlType = value;}
+ }
+
+ internal SQL_C_TYPE SqlCType
+ {
+ get {
+
+ if ( _sqlCType == SQL_C_TYPE.UNASSIGNED)
+ _sqlCType =
OdbcTypeConverter.ConvertToSqlCType (OdbcType);
+ return _sqlCType;
+ }
+ set {_sqlCType = value;}
+ }
+
+ internal void UpdateTypes (SQL_TYPE sqlType)
+ {
+ SqlType = sqlType;
+ OdbcTypeConverter.TypeMap map =
OdbcTypeConverter.GetTypeMap (SqlType);
+ OdbcType = map.OdbcType;
+ SqlCType = map.SqlCType;
+ }
+
+
}
}
Modified: trunk/mcs/class/System.Data/System.Data.Odbc/OdbcDataReader.cs
===================================================================
--- trunk/mcs/class/System.Data/System.Data.Odbc/OdbcDataReader.cs
2005-03-10 08:59:37 UTC (rev 41639)
+++ trunk/mcs/class/System.Data/System.Data.Odbc/OdbcDataReader.cs
2005-03-10 09:13:45 UTC (rev 41640)
@@ -159,8 +159,7 @@
throw new OdbcException(new
OdbcError("SQLDescribeCol",OdbcHandleType.Stmt,hstmt));
colname=System.Text.Encoding.Default.GetString(colname_buffer);
colname=colname.Replace((char) 0,' ').Trim();
- OdbcType t = libodbc.NativeToOdbcType (
(OdbcCType) dt);
- OdbcColumn c=new OdbcColumn(colname, t);
+ OdbcColumn c=new OdbcColumn(colname, (SQL_TYPE)
dt);
c.AllowDBNull=(Nullable!=0);
c.Digits=DecDigits;
if (c.IsStringType)
@@ -212,7 +211,7 @@
byte [] tbuff = new byte [length+1];
length = buffer == null ? 0 : length;
- ret=libodbc.SQLGetData (hstmt, (ushort) (ordinal+1),
OdbcCType.Binary, tbuff, length,
+ ret=libodbc.SQLGetData (hstmt, (ushort) (ordinal+1),
SQL_C_TYPE.BINARY, tbuff, length,
ref outsize);
if (ret == OdbcReturn.NoData)
@@ -430,10 +429,9 @@
schemaRow.AcceptChanges();
}
-
+ dataTableSchema.AcceptChanges();
}
- dataTableSchema.AcceptChanges();
- return dataTableSchema;
+ return dataTableSchema;
}
public string GetString (int ordinal)
@@ -465,15 +463,15 @@
// Check cached values
if (col.Value==null)
{
-
- // odbc help file
+ // odbc help file
//
mk:@MSITStore:C:\program%20files\Microsoft%20Data%20Access%20SDK\Docs\odbc.chm::/htm/odbcc_data_types.htm
switch (col.OdbcType)
{
case OdbcType.Decimal:
bufsize=50;
- buffer=new byte[bufsize]; //
According to sqlext.h, use SQL_CHAR for decimal
- ret=libodbc.SQLGetData(hstmt,
ColIndex, OdbcCType.Char, buffer, bufsize, ref outsize);
+ buffer=new byte[bufsize]; //
According to sqlext.h, use SQL_CHAR for decima.
+ // 2005 03 10 : this now works
with unixodbc with numeric c type.
+ ret=libodbc.SQLGetData(hstmt,
ColIndex, col.SqlCType, buffer, bufsize, ref outsize);
byte[] temp = new byte[outsize];
for (int i=0;i<outsize;i++)
temp[i]=buffer[i];
@@ -483,48 +481,48 @@
break;
case OdbcType.TinyInt:
short short_data=0;
- ret=libodbc.SQLGetData(hstmt,
ColIndex, OdbcCType.TinyInt, ref short_data, 0, ref outsize);
+ ret=libodbc.SQLGetData(hstmt,
ColIndex, col.SqlCType, ref short_data, 0, ref outsize);
DataValue=System.Convert.ToByte(short_data);
break;
case OdbcType.Int:
int int_data=0;
- ret=libodbc.SQLGetData(hstmt,
ColIndex, OdbcCType.Int, ref int_data, 0, ref outsize);
+ ret=libodbc.SQLGetData(hstmt,
ColIndex, col.SqlCType, ref int_data, 0, ref outsize);
DataValue=int_data;
break;
case OdbcType.SmallInt:
short sint_data=0;
- ret=libodbc.SQLGetData(hstmt,
ColIndex, OdbcCType.SmallInt, ref sint_data, 0, ref outsize);
+ ret=libodbc.SQLGetData(hstmt,
ColIndex, col.SqlCType, ref sint_data, 0, ref outsize);
DataValue=sint_data;
break;
case OdbcType.BigInt:
long long_data=0;
- ret=libodbc.SQLGetData(hstmt,
ColIndex, OdbcCType.SignedBigInt, ref long_data, 0, ref outsize);
+ ret=libodbc.SQLGetData(hstmt,
ColIndex, col.SqlCType, ref long_data, 0, ref outsize);
DataValue=long_data;
break;
case OdbcType.NVarChar:
bufsize=col.MaxLength*2+1; //
Unicode is double byte
buffer=new byte[bufsize];
- ret=libodbc.SQLGetData(hstmt,
ColIndex, OdbcCType.NVarChar, buffer, bufsize, ref outsize);
+ ret=libodbc.SQLGetData(hstmt,
ColIndex, col.SqlCType, buffer, bufsize, ref outsize);
if (outsize!=-1)
DataValue=System.Text.Encoding.Unicode.GetString(buffer,0,outsize);
break;
case OdbcType.VarChar:
bufsize=col.MaxLength+1;
buffer=new byte[bufsize]; //
According to sqlext.h, use SQL_CHAR for both char and varchar
- ret=libodbc.SQLGetData(hstmt,
ColIndex, OdbcCType.Char, buffer, bufsize, ref outsize);
+ ret=libodbc.SQLGetData(hstmt,
ColIndex, col.SqlCType, buffer, bufsize, ref outsize);
if (outsize!=-1)
DataValue=System.Text.Encoding.Default.GetString(buffer,0,outsize);
break;
case OdbcType.Real:
float float_data=0;
- ret=libodbc.SQLGetData(hstmt,
ColIndex, OdbcCType.Real, ref float_data, 0, ref outsize);
+ ret=libodbc.SQLGetData(hstmt,
ColIndex, col.SqlCType, ref float_data, 0, ref outsize);
DataValue=float_data;
break;
case OdbcType.Double:
double double_data=0;
- ret=libodbc.SQLGetData(hstmt,
ColIndex, OdbcCType.Double, ref double_data, 0, ref outsize);
+ ret=libodbc.SQLGetData(hstmt,
ColIndex, col.SqlCType, ref double_data, 0, ref outsize);
DataValue=double_data;
break;
case OdbcType.Timestamp:
@@ -532,15 +530,8 @@
case OdbcType.Date:
case OdbcType.Time:
OdbcTimestamp ts_data=new
OdbcTimestamp();
- if (col.OdbcType ==
OdbcType.Timestamp)
-
ret=libodbc.SQLGetData(hstmt, ColIndex, OdbcCType.Timestamp, ref ts_data, 0,
ref outsize);
- else if (col.OdbcType ==
OdbcType.DateTime)
-
ret=libodbc.SQLGetData(hstmt, ColIndex, OdbcCType.DateTime, ref ts_data, 0, ref
outsize);
- else if (col.OdbcType ==
OdbcType.Date)
-
ret=libodbc.SQLGetData(hstmt, ColIndex, OdbcCType.Date, ref ts_data, 0, ref
outsize);
- else // FIXME: how to get TIME
datatype ??
-
ret=libodbc.SQLGetData(hstmt, ColIndex, OdbcCType.DateTime, ref ts_data, 0, ref
outsize);
- if (outsize!=-1) // This means
SQL_NULL_DATA
+ ret=libodbc.SQLGetData(hstmt,
ColIndex, col.SqlCType, ref ts_data, 0, ref outsize);
+ if (outsize!=-1) // This means
SQL_NULL_DATA
DataValue=new
DateTime(ts_data.year,ts_data.month,ts_data.day,ts_data.hour,
ts_data.minute,ts_data.second,Convert.ToInt32(ts_data.fraction));
break;
@@ -555,7 +546,7 @@
default:
bufsize=255;
buffer=new byte[bufsize];
- ret=libodbc.SQLGetData(hstmt,
ColIndex, OdbcCType.Char, buffer, bufsize, ref outsize);
+ ret=libodbc.SQLGetData(hstmt,
ColIndex, SQL_C_TYPE.CHAR, buffer, bufsize, ref outsize);
DataValue=System.Text.Encoding.Default.GetString(buffer);
break;
}
Modified: trunk/mcs/class/System.Data/System.Data.Odbc/OdbcParameter.cs
===================================================================
--- trunk/mcs/class/System.Data/System.Data.Odbc/OdbcParameter.cs
2005-03-10 08:59:37 UTC (rev 41639)
+++ trunk/mcs/class/System.Data/System.Data.Odbc/OdbcParameter.cs
2005-03-10 09:13:45 UTC (rev 41640)
@@ -51,8 +51,8 @@
DataRowVersion sourceVersion;
string sourceColumn;
ParameterDirection direction;
- OdbcType odbcType;
- DbType dbType;
+ OdbcType odbcType = OdbcType.NVarChar;
+ DbType dbType = DbType.String;
OdbcParameterCollection container = null;
// Buffers for parameter value based on type. Currently I've
only optimized
@@ -249,16 +249,22 @@
setBuffer();
// Convert System.Data.ParameterDirection into odbc enum
- OdbcInputOutputDirection paramdir =
libodbc.ConvertParameterDirection(this.direction);
- // Bind parameter based on type
- if (odbcType == OdbcType.Int)
- ret = libodbc.SQLBindParameter(hstmt,
(ushort)ParamNum, (short)paramdir,
- (short)odbcType, (short)odbcType,
Convert.ToUInt32(size),
- 0, ref intbuf, 0, 0);
- else
- ret = libodbc.SQLBindParameter(hstmt,
(ushort)ParamNum, (short)paramdir,
- (short)OdbcType.Char, (short)odbcType,
Convert.ToUInt32(size),
- 0, buffer, 0, 0);
+ OdbcInputOutputDirection paramdir =
libodbc.ConvertParameterDirection(this.direction);
+
+ SQL_C_TYPE ctype = OdbcTypeConverter.ConvertToSqlCType
(odbcType);
+ SQL_TYPE sqltype =
OdbcTypeConverter.ConvertToSqlType (odbcType);
+
+ // Bind parameter based on type
+ if (odbcType == OdbcType.Int)
+ ret = libodbc.SQLBindParameter(hstmt,
(ushort)ParamNum, (short)paramdir,
+ ctype, sqltype,
Convert.ToUInt32(size),
+ 0, ref intbuf,
0, 0);
+ else
+ ret = libodbc.SQLBindParameter(hstmt,
(ushort)ParamNum, (short)paramdir,
+ ctype, sqltype,
Convert.ToUInt32(size),
+ 0, buffer, 0,
0);
+
+
// Check for error condition
if ((ret != OdbcReturn.Success) && (ret !=
OdbcReturn.SuccessWithInfo))
throw new OdbcException(new
OdbcError("SQLBindParam", OdbcHandleType.Stmt, hstmt));
@@ -277,6 +283,8 @@
int minSize = size;
minSize = size > 20 ? size : 20;
+ if (ParamValue is String)
+ minSize += 2; // for enclosing apos
if (buffer == null || buffer.Length < minSize)
buffer = new byte[minSize];
else
Modified: trunk/mcs/class/System.Data/System.Data.Odbc/OdbcType.cs
===================================================================
--- trunk/mcs/class/System.Data/System.Data.Odbc/OdbcType.cs 2005-03-10
08:59:37 UTC (rev 41639)
+++ trunk/mcs/class/System.Data/System.Data.Odbc/OdbcType.cs 2005-03-10
09:13:45 UTC (rev 41640)
@@ -2,6 +2,7 @@
// System.Data.Odbc.OdbcType
//
// Author:
+// Sureshkumar T <[EMAIL PROTECTED]> 2005.
// Brian Ritchie
//
// Copyright (C) Brian Ritchie, 2002
@@ -72,44 +73,95 @@
// and SQL_TYPE_TIMESTAMP (with instances of #define in the header
file of 91, 92, and 93),
// respectively.
- // Unmapped SQL Types
- //
- //#define SQL_FLOAT
6
- // could map to SQL_DOUBLE?
- //#define SQL_INTERVAL
10
- // could map to SmallDateTime?
-
// This internal enum is used as mapping types into database drivers.
// This is essentially a map between public OdbcType to C types for
- // Odbc to call into driver.
- internal enum OdbcCType // Native Types
+ // Odbc to call into driver. These values are taken from sql.h &
sqlext.h.
+ internal enum SQL_TYPE : short
{
- SignedBigInt=-25, // SQL_C_SBIGINT
- BigInt=-5, // SQL_BIGINT
- Binary=-2, // SQL_BINARY
- Bit=-7, // SQL_BIT
- Char=1, // SQL_CHAR
- Date=91, // SQL_TYPE_DATE
- DateTime=9, // SQL_DATETIME
- Decimal=3, // SQL_DECIMAL
- Double=8, // SQL_DOUBLE
- Image=-4, // SQL_LONGVARBINARY
- Int=4, // SQL_INTEGER
- NChar=-95, // SQL_UNICODE_CHAR
- NText=-97, // SQL_UNICODE_LONGVARCHAR
- Numeric=2, // SQL_NUMERIC
- NVarChar=-96, // SQL_UNICODE_VARCHAR
- Real=7, // SQL_REAL
- SmallDateTime=0,// ??????????????????????????
- SmallInt=5, // SQL_SMALLINT
- Time=92, // SQL_TYPE_TIME
- Text=-1, // SQL_LONGVARCHAR
- Timestamp=93, // SQL_TYPE_TIMESTAMP
- TinyInt=-6, // SQL_TINYINT
- UniqueIdentifier=-11, // SQL_GUID
- VarBinary=-3, // SQL_VARBINARY
- VarChar=12 // SQL_VARCHAR
+ BIGINT = (-5),
+ BINARY = (-2),
+ BIT = (-7),
+ CHAR = 1,
+ DATE = 9,
+ DECIMAL = 3,
+ DOUBLE = 8,
+ GUID = (-11),
+ INTEGER = 4,
+ INTERVAL_DAY = (100 + 3),
+ INTERVAL_DAY_TO_HOUR = (100 + 8),
+ INTERVAL_DAY_TO_MINUTE = (100 + 9),
+ INTERVAL_DAY_TO_SECOND = (100 + 10),
+ INTERVAL_HOUR = (100 + 4),
+ INTERVAL_HOUR_TO_MINUTE = (100 + 11),
+ INTERVAL_HOUR_TO_SECOND = (100 + 12),
+ INTERVAL_MINUTE = (100 + 5),
+ INTERVAL_MINUTE_TO_SECOND = (100 + 13),
+ INTERVAL_MONTH = (100 + 2),
+ INTERVAL_SECOND = (100 + 6),
+ INTERVAL_YEAR = (100 + 1),
+ INTERVAL_YEAR_TO_MONTH = (100 + 7),
+ LONGVARBINARY = (-4),
+ LONGVARCHAR = (-1),
+ NUMERIC = 2,
+ REAL = 7,
+ SMALLINT = 5,
+ TIME = 10,
+ TIMESTAMP = 11,
+ TINYINT = (-6),
+ TYPE_DATE = 91,
+ TYPE_TIME = 92,
+ TYPE_TIMESTAMP = 93,
+ VARBINARY = (-3),
+ VARCHAR = 12,
+ WCHAR = (-8),
+ WLONGVARCHAR = (-10),
+ WVARCHAR = (-9),
+ UNASSIGNED = Int16.MaxValue
}
+ public enum SQL_C_TYPE : short
+ {
+ BINARY = (-2),
+ BIT = (-7),
+ BOOKMARK = (4 +(-22)),
+ CHAR = 1,
+ DATE = 9,
+ DEFAULT = 99,
+ DOUBLE = 8,
+ FLOAT = 7,
+ GUID = (-11),
+ INTERVAL_DAY = (100 + 3),
+ INTERVAL_DAY_TO_HOUR = (100 + 8),
+ INTERVAL_DAY_TO_MINUTE = (100 + 9),
+ INTERVAL_DAY_TO_SECOND = (100 + 10),
+ INTERVAL_HOUR = (100 + 4),
+ INTERVAL_HOUR_TO_MINUTE = (100 + 11),
+ INTERVAL_HOUR_TO_SECOND = (100 + 12),
+ INTERVAL_MINUTE = (100 + 5),
+ INTERVAL_MINUTE_TO_SECOND = (100 + 13),
+ INTERVAL_MONTH = (100 + 2),
+ INTERVAL_SECOND = (100 + 6),
+ INTERVAL_YEAR = (100 + 1),
+ INTERVAL_YEAR_TO_MONTH = (100 + 7),
+ LONG = 4,
+ NUMERIC = 2,
+ SBIGINT = ((-5)+(-20)),
+ SHORT = 5,
+ SLONG = (4 +(-20)),
+ SSHORT = (5 +(-20)),
+ STINYINT = ((-6)+(-20)),
+ TCHAR = 1,
+ TIME = 10,
+ TIMESTAMP = 11,
+ TINYINT = (-6),
+ TYPE_DATE = 91,
+ TYPE_TIME = 92,
+ TYPE_TIMESTAMP = 93,
+ UBIGINT = ((-5)+(-22)),
+ ULONG = (4 +(-22)),
+ USHORT = (5 +(-22)),
+ UTINYINT = ((-6)+(-22)),
+ WCHAR = (-8),
+ UNASSIGNED = Int16.MaxValue
+ }
}
-
Added: trunk/mcs/class/System.Data/System.Data.Odbc/OdbcTypeConverter.cs
===================================================================
--- trunk/mcs/class/System.Data/System.Data.Odbc/OdbcTypeConverter.cs
2005-03-10 08:59:37 UTC (rev 41639)
+++ trunk/mcs/class/System.Data/System.Data.Odbc/OdbcTypeConverter.cs
2005-03-10 09:13:45 UTC (rev 41640)
@@ -0,0 +1,417 @@
+//
+// System.Data.Odbc.OdbcTypeConverter
+//
+// Author:
+// Sureshkumar T <[EMAIL PROTECTED]>
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+//
+//
+// * Type mapping between various odbc driver types.
+// For further infomartion between these mapping visit following msdn site
+//
+// *
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/
+// odbcc_data_types.asp
+// *
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/
+// odbcconverting_data_from_c_to_sql_data_types.asp
+// *
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/
+// odbcconverting_data_from_sql_to_c_data_types.asp
+// *
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/
+// odbcparameter_data_types.asp
+// *
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/
+// html/frlrfsystemdataodbcodbctypeclasstopic.asp
+//
+//
+// OdbcType SQL_C_TYPE SQL_TYPE
+// ===================================================================
+// BigInt SQL_C_TYPE.SBIGINT SQL_TYPE.BIGINT
+// Binary SQL_C_TYPE.BINARY SQL_TYPE.BINARY
+// Bit SQL_C_TYPE.BIT SQL_TYPE.BIT
+// Char SQL_C_TYPE.CHAR SQL_TYPE.CHAR
+// Date SQL_C_TYPE.TYPE_DATE SQL_TYPE.TYPE_DATE
+// DateTime SQL_C_TYPE.TIMESTAMP SQL_TYPE.TIMESTAMP
+// Decimal SQL_C_TYPE.NUMERIC SQL_TYPE.NUMERIC
+// Double SQL_C_TYPE.DOUBLE SQL_TYPE.DOUBLE
+// Image SQL_C_TYPE.BINARY SQL_TYPE.BINARY
+// Int SQL_C_TYPE.LONG SQL_TYPE.INTEGER
+// NChar SQL_C_TYPE.WCHAR SQL_TYPE.WCHAR
+// NText SQL_C_TYPE.WCHAR SQL_TYPE.WLONGVARCHAR
+// Numeric SQL_C_TYPE.NUMERIC SQL_TYPE.NUMERIC
+// NVarChar SQL_C_TYPE.WCHAR SQL_TYPE.WVARCHAR
+// Real SQL_C_TYPE.FLOAT SQL_TYPE.REAL
+// SignedBigInt SQL_C_TYPE.SBIGINT SQL_TYPE.BIGINT
+// SmallDateTime SQL_C_TYPE.TIMESTAMP SQL_TYPE.TIMESTAMP
+// SmallInt SQL_C_TYPE.SHORT SQL_TYPE.SMALLINT
+// Text SQL_C_TYPE.WCHAR SQL_TYPE.LONGVARCHAR
+// Time SQL_C_TYPE.TYPE_TIME SQL_TYPE.TYPE_TIME
+// Timestamp SQL_C_TYPE.BINARY SQL_TYPE.BINARY
+// TinyInt SQL_C_TYPE.UTINYINT SQL_TYPE.TINYINT
+// UniqueIdentifier SQL_C_TYPE.GUID SQL_TYPE.GUID
+// VarBinary SQL_C_TYPE.BINARY SQL_TYPE.VARBINARY
+// VarChar SQL_C_TYPE.WCHAR SQL_TYPE.WVARCHAR
+//====================================================================
+
+
+using System.Data;
+using System.Collections;
+using System.Data.Common;
+
+namespace System.Data.Odbc
+{
+ internal sealed class OdbcTypeConverter
+ {
+ internal struct TypeMap
+ {
+ public const short DefaultForOdbcType = 1;
+ public const short DefaultForSQLCType = 1<<1;
+ public const short DefaultForSQLType = 1<<2;
+ public const short DefaultAll =
(DefaultForOdbcType |
+
DefaultForSQLCType |
+
DefaultForSQLType);
+ public OdbcType OdbcType;
+ public SQL_C_TYPE SqlCType;
+ public SQL_TYPE SqlType;
+ public short BitMask;
+
+ public TypeMap (OdbcType odbcType, SQL_C_TYPE
sqlCType, SQL_TYPE sqlType)
+ {
+ OdbcType = odbcType;
+ SqlType = sqlType;
+ SqlCType = sqlCType;
+ BitMask = DefaultForOdbcType
+ | DefaultForSQLCType
+ | DefaultForSQLType
+ ;
+ }
+
+ public TypeMap (OdbcType odbcType, SQL_C_TYPE
sqlCType, SQL_TYPE sqlType, short defaultFlags)
+ : this (odbcType, sqlCType, sqlType)
+ {
+ BitMask = defaultFlags;
+ }
+
+ }
+
+
+ // FIXME: Write a binary search to make faster
+ internal class MapCollection : CollectionBase
+ {
+ public TypeMap this [OdbcType odbcType]
+ {
+ get {
+ foreach (TypeMap map in List){
+ if (map.OdbcType == odbcType
+ && (map.BitMask &
TypeMap.DefaultForOdbcType) > 0 )
+ return map;
+ }
+ throw new ArgumentException
(String.Format ("Type mapping for odbc type {0} is not found",
+
odbcType.ToString ()
+
)
+ );
+ }
+ set {
+ int i = IndexOf (odbcType);
+ if (i == -1)
+ Add (value);
+ List [i] = value;
+ }
+ }
+
+ public TypeMap this [SQL_C_TYPE sqlCType]
+ {
+ get {
+ foreach (TypeMap map in List){
+ if (map.SqlCType == sqlCType
+ && (map.BitMask &
TypeMap.DefaultForSQLCType) > 0 )
+ return map;
+ }
+ throw new ArgumentException
(String.Format ("Type mapping for odbc type {0} is not found",
+
sqlCType.ToString ()
+
)
+ );
+ }
+ set {
+ int i = IndexOf (sqlCType);
+ if (i == -1)
+ Add (value);
+ List [i] = value;
+ }
+
+ }
+
+
+ public TypeMap this [SQL_TYPE sqlType]
+ {
+ get {
+ foreach (TypeMap map in List){
+ if (map.SqlType == sqlType
+ && (map.BitMask &
TypeMap.DefaultForSQLType) > 0 )
+ return map;
+ }
+ throw new ArgumentException
(String.Format ("Type mapping for odbc type {0} is not found",
+
sqlType.ToString ()
+
)
+ );
+ }
+ set {
+ int i = IndexOf (sqlType);
+ if (i == -1)
+ Add (value);
+ List [i] = value;
+ }
+
+ }
+
+ public TypeMap this [int index]
+ {
+ get { return (TypeMap) List [index];}
+ set { List [index] = value;}
+ }
+
+
+
+ public int IndexOf (OdbcType odbcType)
+ {
+ for (int i=0; i < List.Count; i++) {
+ TypeMap map = (TypeMap) List [i];
+ if (map.OdbcType == odbcType
+ && (map.BitMask &
TypeMap.DefaultForOdbcType) > 0 )
+ return i;
+ }
+ return -1;
+ }
+
+ public int IndexOf (SQL_C_TYPE sqlCType)
+ {
+ for (int i=0; i < List.Count; i++) {
+ TypeMap map = (TypeMap) List [i];
+ if (map.SqlCType == sqlCType
+ && (map.BitMask &
TypeMap.DefaultForSQLCType) > 0 )
+ return i;
+ }
+ return -1;
+ }
+
+ public int IndexOf (SQL_TYPE sqlType)
+ {
+ for (int i=0; i < List.Count; i++) {
+ TypeMap map = (TypeMap) List [i];
+ if (map.SqlType == sqlType
+ && (map.BitMask &
TypeMap.DefaultForSQLType) > 0 )
+ return i;
+ }
+ return -1;
+ }
+
+ public int Add (TypeMap map)
+ {
+ return List.Add (map);
+ }
+
+ protected override void OnValidate (object value)
+ {
+ if (value.GetType () != typeof (TypeMap))
+ throw new ArgumentException ("value is
not of type TypeMap");
+ }
+
+ }
+
+
+ private static MapCollection OdbcTypeMap;
+
+ static OdbcTypeConverter ()
+ {
+ lock (typeof (OdbcTypeConverter)) {
+ if (OdbcTypeMap == null) {
+ OdbcTypeMap = new MapCollection ();
+ OdbcTypeMap.Add (new TypeMap
(OdbcType.BigInt, SQL_C_TYPE.SBIGINT, SQL_TYPE.BIGINT
));
+ OdbcTypeMap.Add (new TypeMap
(OdbcType.Binary, SQL_C_TYPE.BINARY, SQL_TYPE.BINARY
));
+ OdbcTypeMap.Add (new TypeMap
(OdbcType.Bit, SQL_C_TYPE.BIT, SQL_TYPE.BIT
));
+ OdbcTypeMap.Add (new TypeMap
(OdbcType.Char, SQL_C_TYPE.CHAR, SQL_TYPE.CHAR
));
+ OdbcTypeMap.Add (new TypeMap
(OdbcType.Date, SQL_C_TYPE.TYPE_DATE, SQL_TYPE.TYPE_DATE
));
+ OdbcTypeMap.Add (new TypeMap
(OdbcType.DateTime, SQL_C_TYPE.TIMESTAMP, SQL_TYPE.TIMESTAMP
));
+ OdbcTypeMap.Add (new TypeMap
(OdbcType.Decimal, SQL_C_TYPE.NUMERIC,
SQL_TYPE.NUMERIC , TypeMap.DefaultAll & (~TypeMap.DefaultForSQLType)));
+ OdbcTypeMap.Add (new TypeMap
(OdbcType.Double, SQL_C_TYPE.DOUBLE, SQL_TYPE.DOUBLE
));
+ OdbcTypeMap.Add (new TypeMap
(OdbcType.Image, SQL_C_TYPE.BINARY, SQL_TYPE.BINARY ,
TypeMap.DefaultAll & (~TypeMap.DefaultForSQLType)));
+ OdbcTypeMap.Add (new TypeMap
(OdbcType.Int, SQL_C_TYPE.LONG, SQL_TYPE.INTEGER
));
+ OdbcTypeMap.Add (new TypeMap
(OdbcType.NChar, SQL_C_TYPE.WCHAR, SQL_TYPE.WCHAR
));
+ OdbcTypeMap.Add (new TypeMap
(OdbcType.NText, SQL_C_TYPE.WCHAR,
SQL_TYPE.WLONGVARCHAR));
+ OdbcTypeMap.Add (new TypeMap
(OdbcType.Numeric, SQL_C_TYPE.NUMERIC,
SQL_TYPE.NUMERIC ));
+ OdbcTypeMap.Add (new TypeMap
(OdbcType.NVarChar, SQL_C_TYPE.WCHAR, SQL_TYPE.WVARCHAR
));
+ OdbcTypeMap.Add (new TypeMap
(OdbcType.Real, SQL_C_TYPE.FLOAT, SQL_TYPE.REAL
));
+ OdbcTypeMap.Add (new TypeMap
(OdbcType.SmallDateTime, SQL_C_TYPE.TIMESTAMP, SQL_TYPE.TIMESTAMP ,
TypeMap.DefaultAll & (~TypeMap.DefaultForSQLType)));
+ OdbcTypeMap.Add (new TypeMap
(OdbcType.SmallInt, SQL_C_TYPE.SHORT, SQL_TYPE.SMALLINT
));
+ OdbcTypeMap.Add (new TypeMap
(OdbcType.Text, SQL_C_TYPE.WCHAR,
SQL_TYPE.LONGVARCHAR));
+ OdbcTypeMap.Add (new TypeMap
(OdbcType.Time, SQL_C_TYPE.TYPE_TIME, SQL_TYPE.TYPE_TIME
));
+ OdbcTypeMap.Add (new TypeMap
(OdbcType.Timestamp, SQL_C_TYPE.BINARY, SQL_TYPE.BINARY ,
TypeMap.DefaultAll & (~TypeMap.DefaultForSQLType)));
+ OdbcTypeMap.Add (new TypeMap
(OdbcType.TinyInt, SQL_C_TYPE.UTINYINT,
SQL_TYPE.TINYINT ));
+ OdbcTypeMap.Add (new TypeMap
(OdbcType.UniqueIdentifier,SQL_C_TYPE.GUID, SQL_TYPE.GUID
));
+ OdbcTypeMap.Add (new TypeMap
(OdbcType.VarBinary, SQL_C_TYPE.BINARY, SQL_TYPE.VARBINARY
));
+ OdbcTypeMap.Add (new TypeMap
(OdbcType.VarChar, SQL_C_TYPE.WCHAR,
SQL_TYPE.WVARCHAR , TypeMap.DefaultAll & (~TypeMap.DefaultForSQLType)));
+ }
+
+ }
+ }
+
+ public static SQL_C_TYPE ConvertToSqlCType (OdbcType type)
+ {
+ return OdbcTypeMap [type].SqlCType;
+ }
+
+ public static SQL_TYPE ConvertToSqlType (OdbcType type)
+ {
+ return OdbcTypeMap [type].SqlType;
+ }
+
+
+ public static OdbcType ConvertToOdbcType (SQL_TYPE sqlType)
+ {
+ // Unmapped SQL Types
+ //
+ //#define SQL_FLOAT 6
+ // could map to SQL_DOUBLE?
+ //#define SQL_INTERVAL 10
+ // could map to SmallDateTime?
+ return GetTypeMap (sqlType).OdbcType;
+ }
+
+ public static TypeMap GetTypeMap (SQL_TYPE sqlType)
+ {
+ TypeMap map;
+ try {
+ map = OdbcTypeMap [sqlType];
+ return map;
+ } catch (ArgumentException) {
+
+ }
+
+ // If not in default translation
+ map = new TypeMap ();
+ map.SqlType = sqlType;
+ switch (sqlType) {
+ case SQL_TYPE.DATE:
+ map.OdbcType = OdbcType.DateTime;
+ map.SqlCType = SQL_C_TYPE.TYPE_DATE;
+ return map;
+
+ case SQL_TYPE.DECIMAL:
+ map.OdbcType = OdbcType.Decimal;
+ map.SqlCType = SQL_C_TYPE.CHAR;
+ return map;
+
+ case SQL_TYPE.INTERVAL_DAY:
+ map.OdbcType = OdbcType.DateTime;
+ map.SqlCType = SQL_C_TYPE.INTERVAL_DAY;
+ return map;
+
+ case SQL_TYPE.INTERVAL_DAY_TO_HOUR:
+ map.OdbcType = OdbcType.DateTime;
+ map.SqlCType = SQL_C_TYPE.INTERVAL_DAY_TO_HOUR;
+ return map;
+
+ case SQL_TYPE.INTERVAL_DAY_TO_MINUTE:
+ map.OdbcType = OdbcType.DateTime;
+ map.SqlCType =
SQL_C_TYPE.INTERVAL_DAY_TO_MINUTE;
+ return map;
+
+ case SQL_TYPE.INTERVAL_DAY_TO_SECOND:
+ map.OdbcType = OdbcType.DateTime;
+ map.SqlCType =
SQL_C_TYPE.INTERVAL_DAY_TO_SECOND;
+ return map;
+
+ case SQL_TYPE.INTERVAL_HOUR:
+ map.OdbcType = OdbcType.DateTime;
+ map.SqlCType = SQL_C_TYPE.INTERVAL_HOUR;
+ return map;
+
+ case SQL_TYPE.INTERVAL_HOUR_TO_MINUTE:
+ map.OdbcType = OdbcType.DateTime;
+ map.SqlCType =
SQL_C_TYPE.INTERVAL_HOUR_TO_MINUTE;
+ return map;
+
+ case SQL_TYPE.INTERVAL_HOUR_TO_SECOND:
+ map.OdbcType = OdbcType.DateTime;
+ map.SqlCType =
SQL_C_TYPE.INTERVAL_HOUR_TO_SECOND;
+ return map;
+
+ case SQL_TYPE.INTERVAL_MINUTE:
+ map.OdbcType = OdbcType.DateTime;
+ map.SqlCType = SQL_C_TYPE.INTERVAL_MINUTE;
+ return map;
+
+ case SQL_TYPE.INTERVAL_MINUTE_TO_SECOND:
+ map.OdbcType = OdbcType.DateTime;
+ map.SqlCType =
SQL_C_TYPE.INTERVAL_MINUTE_TO_SECOND;
+ return map;
+
+ case SQL_TYPE.INTERVAL_MONTH:
+ map.OdbcType = OdbcType.DateTime;
+ map.SqlCType = SQL_C_TYPE.INTERVAL_MONTH;
+ return map;
+
+ case SQL_TYPE.INTERVAL_SECOND:
+ map.OdbcType = OdbcType.DateTime;
+ map.SqlCType = SQL_C_TYPE.INTERVAL_SECOND;
+ return map;
+
+ case SQL_TYPE.INTERVAL_YEAR:
+ map.OdbcType = OdbcType.DateTime;
+ map.SqlCType = SQL_C_TYPE.INTERVAL_YEAR;
+ return map;
+
+ case SQL_TYPE.INTERVAL_YEAR_TO_MONTH:
+ map.OdbcType = OdbcType.DateTime;
+ map.SqlCType =
SQL_C_TYPE.INTERVAL_YEAR_TO_MONTH;
+ return map;
+
+ case SQL_TYPE.LONGVARBINARY:
+ map.OdbcType = OdbcType.Binary;
+ map.SqlCType = SQL_C_TYPE.BINARY;
+ return map;
+
+ case SQL_TYPE.TIME:
+ map.OdbcType = OdbcType.DateTime;
+ map.SqlCType = SQL_C_TYPE.TIME;
+ return map;
+
+ case SQL_TYPE.TYPE_TIMESTAMP:
+ map.OdbcType = OdbcType.DateTime;
+ map.SqlCType = SQL_C_TYPE.TIMESTAMP;
+ return map;
+
+ case SQL_TYPE.VARCHAR:
+ map.OdbcType = OdbcType.VarChar;
+ map.SqlCType = SQL_C_TYPE.CHAR;
+ return map;
+
+ default:
+ map.OdbcType = OdbcType.NVarChar;
+ map.SqlCType = SQL_C_TYPE.WCHAR;
+ return map;
+ }
+ }
+
+ }
+}
Property changes on:
trunk/mcs/class/System.Data/System.Data.Odbc/OdbcTypeConverter.cs
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/mcs/class/System.Data/System.Data.Odbc/libodbc.cs
===================================================================
--- trunk/mcs/class/System.Data/System.Data.Odbc/libodbc.cs 2005-03-10
08:59:37 UTC (rev 41639)
+++ trunk/mcs/class/System.Data/System.Data.Odbc/libodbc.cs 2005-03-10
09:13:45 UTC (rev 41640)
@@ -3,6 +3,7 @@
//
// Authors:
// Brian Ritchie ([EMAIL PROTECTED])
+// Sureshkumar T ([EMAIL PROTECTED])
//
//
// Copyright (C) Brian Ritchie, 2002
@@ -158,28 +159,28 @@
internal static extern OdbcReturn SQLFetch (IntPtr
StatementHandle);
[DllImport("odbc32.dll")]
- internal static extern OdbcReturn SQLGetData (IntPtr
StatementHandle, ushort ColumnNumber, OdbcCType TargetType, ref bool TargetPtr,
int BufferLen, ref int Len);
+ internal static extern OdbcReturn SQLGetData (IntPtr
StatementHandle, ushort ColumnNumber, SQL_C_TYPE TargetType, ref bool
TargetPtr, int BufferLen, ref int Len);
[DllImport("odbc32.dll")]
- internal static extern OdbcReturn SQLGetData (IntPtr
StatementHandle, ushort ColumnNumber, OdbcCType TargetType, ref double
TargetPtr, int BufferLen, ref int Len);
+ internal static extern OdbcReturn SQLGetData (IntPtr
StatementHandle, ushort ColumnNumber, SQL_C_TYPE TargetType, ref double
TargetPtr, int BufferLen, ref int Len);
[DllImport("odbc32.dll")]
- internal static extern OdbcReturn SQLGetData (IntPtr
StatementHandle, ushort ColumnNumber, OdbcCType TargetType, ref long TargetPtr,
int BufferLen, ref int Len);
+ internal static extern OdbcReturn SQLGetData (IntPtr
StatementHandle, ushort ColumnNumber, SQL_C_TYPE TargetType, ref long
TargetPtr, int BufferLen, ref int Len);
[DllImport("odbc32.dll")]
- internal static extern OdbcReturn SQLGetData (IntPtr
StatementHandle, ushort ColumnNumber, OdbcCType TargetType, ref short
TargetPtr, int BufferLen, ref int Len);
+ internal static extern OdbcReturn SQLGetData (IntPtr
StatementHandle, ushort ColumnNumber, SQL_C_TYPE TargetType, ref short
TargetPtr, int BufferLen, ref int Len);
[DllImport("odbc32.dll")]
- internal static extern OdbcReturn SQLGetData (IntPtr
StatementHandle, ushort ColumnNumber, OdbcCType TargetType, ref float
TargetPtr, int BufferLen, ref int Len);
+ internal static extern OdbcReturn SQLGetData (IntPtr
StatementHandle, ushort ColumnNumber, SQL_C_TYPE TargetType, ref float
TargetPtr, int BufferLen, ref int Len);
[DllImport("odbc32.dll")]
- internal static extern OdbcReturn SQLGetData (IntPtr
StatementHandle, ushort ColumnNumber, OdbcCType TargetType, ref OdbcTimestamp
TargetPtr, int BufferLen, ref int Len);
+ internal static extern OdbcReturn SQLGetData (IntPtr
StatementHandle, ushort ColumnNumber, SQL_C_TYPE TargetType, ref OdbcTimestamp
TargetPtr, int BufferLen, ref int Len);
[DllImport("odbc32.dll")]
- internal static extern OdbcReturn SQLGetData (IntPtr
StatementHandle, ushort ColumnNumber, OdbcCType TargetType, ref int TargetPtr,
int BufferLen, ref int Len);
+ internal static extern OdbcReturn SQLGetData (IntPtr
StatementHandle, ushort ColumnNumber, SQL_C_TYPE TargetType, ref int TargetPtr,
int BufferLen, ref int Len);
[DllImport("odbc32.dll")]
- internal static extern OdbcReturn SQLGetData (IntPtr
StatementHandle, ushort ColumnNumber, OdbcCType TargetType, byte[] TargetPtr,
int BufferLen, ref int Len);
+ internal static extern OdbcReturn SQLGetData (IntPtr
StatementHandle, ushort ColumnNumber, SQL_C_TYPE TargetType, byte[] TargetPtr,
int BufferLen, ref int Len);
[DllImport("odbc32.dll")]
internal static extern OdbcReturn SQLDescribeCol(IntPtr
StatementHandle, ushort ColumnNumber, byte[] ColumnName, short BufferLength,
ref short NameLength, ref short DataType, ref uint ColumnSize, ref short
DecimalDigits, ref short Nullable);
@@ -204,12 +205,12 @@
[DllImport("odbc32.dll")]
internal static extern OdbcReturn SQLBindParameter(IntPtr
StatementHandle, ushort ParamNum,
- short InputOutputType, short ValueType, short
ParamType, uint ColSize,
+ short InputOutputType, SQL_C_TYPE ValueType,
SQL_TYPE ParamType, uint ColSize,
short DecimalDigits, byte[] ParamValue, int
BufLen, int StrLen);
[DllImport("odbc32.dll")]
internal static extern OdbcReturn SQLBindParameter(IntPtr
StatementHandle, ushort ParamNum,
- short InputOutputType, short ValueType, short
ParamType, uint ColSize,
+ short InputOutputType, SQL_C_TYPE ValueType,
SQL_TYPE ParamType, uint ColSize,
short DecimalDigits, ref int ParamValue, int
BufLen, int StrLen);
[DllImport("odbc32.dll")]
@@ -262,65 +263,5 @@
ref short
remainingStrLen);
- #region Type Utilities
- internal static OdbcType NativeToOdbcType (OdbcCType native)
- {
- switch (native)
- {
- case OdbcCType.SignedBigInt: // SQL_C_SBIGINT
- return OdbcType.BigInt;
- case OdbcCType.BigInt: // SQL_BIGINT
- return OdbcType.BigInt;
- case OdbcCType.Binary: // SQL_BINARY
- return OdbcType.Binary;
- case OdbcCType.Bit: // SQL_BIT
- return OdbcType.Bit;
- case OdbcCType.Char: // SQL_CHAR
- return OdbcType.Char;
- case OdbcCType.Date: // SQL_TYPE_DATE
- return OdbcType.Date;
- case OdbcCType.DateTime: // SQL_DATETIME
- return OdbcType.DateTime;
- case OdbcCType.Decimal: // SQL_DECIMAL
- return OdbcType.Decimal;
- case OdbcCType.Double: // SQL_DOUBLE
- return OdbcType.Double;
- case OdbcCType.Image: // SQL_LONGVARBINARY
- return OdbcType.Image;
- case OdbcCType.Int: // SQL_INTEGER
- return OdbcType.Int;
- case OdbcCType.NChar: // SQL_UNICODE_CHAR
- return OdbcType.NChar;
- case OdbcCType.NText: // SQL_UNICODE_LONGVARCHAR
- return OdbcType.NText;
- case OdbcCType.Numeric: // SQL_NUMERIC
- return OdbcType.Numeric;
- case OdbcCType.NVarChar: // SQL_UNICODE_VARCHAR
- return OdbcType.NVarChar;
- case OdbcCType.Real: // SQL_REAL
- return OdbcType.Real;
- case OdbcCType.SmallDateTime: //
??????????????????????????
- return OdbcType.SmallDateTime;
- case OdbcCType.SmallInt: // SQL_SMALLINT
- return OdbcType.SmallInt;
- case OdbcCType.Time: // SQL_TYPE_TIME
- return OdbcType.Time;
- case OdbcCType.Text: // SQL_LONGVARCHAR
- return OdbcType.Text;
- case OdbcCType.Timestamp: // SQL_TYPE_TIMESTAMP
- return OdbcType.Timestamp;
- case OdbcCType.TinyInt: // SQL_TINYINT
- return OdbcType.TinyInt;
- case OdbcCType.UniqueIdentifier: // SQL_GUID
- return OdbcType.UniqueIdentifier;
- case OdbcCType.VarBinary: // SQL_VARBINARY
- return OdbcType.VarBinary;
- case OdbcCType.VarChar: // SQL_VARCHAR
- return OdbcType.VarChar;
- }
- throw new ArgumentException ("Invalid Native Type");
- }
- #endregion // Type Utilities
-
}
}
Modified: trunk/mcs/class/System.Data/System.Data.dll.sources
===================================================================
--- trunk/mcs/class/System.Data/System.Data.dll.sources 2005-03-10 08:59:37 UTC
(rev 41639)
+++ trunk/mcs/class/System.Data/System.Data.dll.sources 2005-03-10 09:13:45 UTC
(rev 41640)
@@ -242,6 +242,7 @@
System.Data.Odbc/OdbcParameterCollection.cs
System.Data.Odbc/OdbcTransaction.cs
System.Data.Odbc/OdbcType.cs
+System.Data.Odbc/OdbcTypeConverter.cs
System.Data.Odbc/libodbc.cs
System.Data.Odbc/OdbcDataAdapter.cs
System.Data.Odbc/OdbcRowUpdatedEventArgs.cs
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches