Author: suresh
Date: 2005-07-07 11:47:53 -0400 (Thu, 07 Jul 2005)
New Revision: 47041

Modified:
   trunk/mcs/class/System.Data/System.Data.Odbc/ChangeLog
   trunk/mcs/class/System.Data/System.Data.Odbc/OdbcParameter.cs
   trunk/mcs/class/System.Data/System.Data.Odbc/OdbcTypeConverter.cs
Log:
2005-07-07  Sureshkumar T  <[EMAIL PROTECTED]>

        * OdbcTypeConverter.cs: ConvertToSqlType & ConvertToSqlCType: map
        VarChar to SQL_C_CHAR and SQL_VARCHAR respective instead of WCHAR
        and WVARCHAR as temporary fix.

        * OdbcParameter.cs: setBuffer: string types need not be quoted.



Modified: trunk/mcs/class/System.Data/System.Data.Odbc/ChangeLog
===================================================================
--- trunk/mcs/class/System.Data/System.Data.Odbc/ChangeLog      2005-07-07 
15:12:40 UTC (rev 47040)
+++ trunk/mcs/class/System.Data/System.Data.Odbc/ChangeLog      2005-07-07 
15:47:53 UTC (rev 47041)
@@ -1,3 +1,11 @@
+2005-07-07  Sureshkumar T  <[EMAIL PROTECTED]>
+
+       * OdbcTypeConverter.cs: ConvertToSqlType & ConvertToSqlCType: map
+       VarChar to SQL_C_CHAR and SQL_VARCHAR respective instead of WCHAR
+       and WVARCHAR as temporary fix.
+
+       * OdbcParameter.cs: setBuffer: string types need not be quoted.
+
 2005-06-28  Sureshkumar T  <[EMAIL PROTECTED]>
 
        * OdbcDataReader.cs: GetPrimaryKeys (): use the length indicator

Modified: trunk/mcs/class/System.Data/System.Data.Odbc/OdbcParameter.cs
===================================================================
--- trunk/mcs/class/System.Data/System.Data.Odbc/OdbcParameter.cs       
2005-07-07 15:12:40 UTC (rev 47040)
+++ trunk/mcs/class/System.Data/System.Data.Odbc/OdbcParameter.cs       
2005-07-07 15:47:53 UTC (rev 47041)
@@ -32,6 +32,7 @@
 //
 
 using System;
+using System.Text;
 using System.Data;
 using System.Data.Common;
 #if NET_2_0
@@ -45,7 +46,7 @@
 #if NET_2_0
         public sealed class OdbcParameter : DbParameterBase, ICloneable
 #else
-       public sealed class OdbcParameter : MarshalByRefObject, 
IDbDataParameter, IDataParameter, ICloneable
+               public sealed class OdbcParameter : MarshalByRefObject, 
IDbDataParameter, IDataParameter, ICloneable
 #endif // NET_2_0
        {
                #region Fields
@@ -124,7 +125,10 @@
                }
 
                [EditorBrowsable (EditorBrowsableState.Advanced)]
-               public OdbcParameter(string name, OdbcType dataType, int size, 
ParameterDirection direction, bool isNullable, byte precision, byte scale, 
string srcColumn, DataRowVersion srcVersion, object value)
+               public OdbcParameter(string name, OdbcType dataType, int size, 
+                                    ParameterDirection direction, bool 
isNullable, 
+                                    byte precision, byte scale, string 
srcColumn, 
+                                    DataRowVersion srcVersion, object value)
                        : this (name, dataType, size, srcColumn)
                {
                        this.Direction = direction;
@@ -177,8 +181,8 @@
                 [EditorBrowsableAttribute (EditorBrowsableState.Advanced)]
                 [DefaultValue (false)]
                public bool IsNullable {
-                       get { return isNullable; }
-                       set { isNullable = value; }
+                       get { return isNullable; }
+                       set { isNullable = value; }
                }
 #endif // ONLY_1_1
 
@@ -277,15 +281,15 @@
 
                #endregion // Properties
 
-               #region Methods
-
-               internal void Bind(IntPtr hstmt, int ParamNum) {
-                       OdbcReturn ret;
-                       // Set up the buffer if we haven't done so yet
-                       if (!bufferIsSet)
-                               setBuffer();
-
-                       // Convert System.Data.ParameterDirection into odbc enum
+               #region Methods
+
+               internal void Bind(IntPtr hstmt, int ParamNum) {
+                       OdbcReturn ret;
+                       // Set up the buffer if we haven't done so yet
+                       if (!bufferIsSet)
+                               setBuffer();
+
+                       // Convert System.Data.ParameterDirection into odbc enum
                        OdbcInputOutputDirection paramdir = 
libodbc.ConvertParameterDirection(this.Direction);
 
                         SQL_C_TYPE ctype = OdbcTypeConverter.ConvertToSqlCType 
(odbcType);
@@ -301,12 +305,12 @@
                                 ret = libodbc.SQLBindParameter(hstmt, 
(ushort)ParamNum, (short)paramdir,
                                                                ctype, sqltype, 
Convert.ToUInt32(Size),
                                                                0, buffer, 
buffer.Length, ref ind);
-                       // Check for error condition
-                       if ((ret != OdbcReturn.Success) && (ret != 
OdbcReturn.SuccessWithInfo))
-                               throw new OdbcException(new 
OdbcError("SQLBindParam", OdbcHandleType.Stmt, hstmt));
-               }
-
-               private void setBuffer() {
+                       // Check for error condition
+                       if ((ret != OdbcReturn.Success) && (ret != 
OdbcReturn.SuccessWithInfo))
+                               throw new OdbcException(new 
OdbcError("SQLBindParam", OdbcHandleType.Stmt, hstmt));
+               }
+
+               private void setBuffer() {
                        // Load buffer with new value
                        if (odbcType == OdbcType.Int)
                                 intbuf = Value == null ? new int () : (int) 
Value;
@@ -325,29 +329,24 @@
                                Buffer.BlockCopy (bits, 0, buffer, 3, 12); // 
copy data
                                for (int j = 16; j < 19; j++) // pad with 0
                                        buffer [j] = 0;
-                        } else {
-                               string paramValueString = Value.ToString();
-                               // Treat everything else as a string
-                               // Init string buffer
-                                if (Value is String)
-                                        paramValueString = 
"\'"+paramValueString+"\'";
-
-                                 int minSize = Size;
-                                 minSize = Size > 20 ? Size : 20;
-                                 if (Value is String)
-                                         minSize += 2; // for enclosing apos
-                                if (buffer == null || buffer.Length < minSize)
-                                         buffer = new byte[minSize];
-                                 else
-                                         buffer.Initialize();
+                        } else {
+                               string paramValueString = Value.ToString();
+                               // Treat everything else as a string
+                               // Init string buffer
+                               int minSize = Size;
+                               minSize = Size > 20 ? Size : 20;
+                               if (buffer == null || buffer.Length < minSize)
+                                       buffer = new byte[minSize];
+                               else
+                                       buffer.Initialize();
                                  
-                                 // Convert value into string and store into 
buffer
-                                 minSize = paramValueString.Length < minSize ? 
paramValueString.Length : minSize;
-                                 
System.Text.Encoding.ASCII.GetBytes(paramValueString, 0, minSize, buffer, 0);
-                       }
-                       bufferIsSet = true;
-               }
-
+                               // Convert value into string and store into 
buffer
+                               minSize = paramValueString.Length < minSize ? 
paramValueString.Length : minSize;
+                               Encoding.ASCII.GetBytes(paramValueString, 0, 
minSize, buffer, 0);
+                       }
+                       bufferIsSet = true;
+               }
+
                [MonoTODO]
                object ICloneable.Clone ()
                {
@@ -363,7 +362,6 @@
                 [MonoTODO]
                 public override void PropertyChanging () 
                 {
-                        throw new NotImplementedException ();
                 }
                 
                 [MonoTODO]

Modified: trunk/mcs/class/System.Data/System.Data.Odbc/OdbcTypeConverter.cs
===================================================================
--- trunk/mcs/class/System.Data/System.Data.Odbc/OdbcTypeConverter.cs   
2005-07-07 15:12:40 UTC (rev 47040)
+++ trunk/mcs/class/System.Data/System.Data.Odbc/OdbcTypeConverter.cs   
2005-07-07 15:47:53 UTC (rev 47041)
@@ -274,11 +274,20 @@
                 
                 public static SQL_C_TYPE ConvertToSqlCType (OdbcType type)
                 {
-                        return OdbcTypeMap [type].SqlCType;
+                       // FIXME: currently, odbc provider does not support 
unicode.
+                       // instead of WCHAR, use currently CHAR
+                       if (type == OdbcType.VarChar)
+                               return SQL_C_TYPE.CHAR;
+                       return OdbcTypeMap [type].SqlCType;
+                               
                 }
                 
                 public static SQL_TYPE ConvertToSqlType (OdbcType type)
                 {
+                       // FIXME: currently, odbc provider does not support 
unicode.
+                       // instead of WVARCHAR, use currently VARCHAR
+                       if (type == OdbcType.VarChar)
+                               return SQL_TYPE.VARCHAR;
                         return OdbcTypeMap [type].SqlType;
                 }
 

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to