2007-09-11 AMC <amc1999@gmail.com>
[mono.git] / mcs / class / System.Data / System.Data.Odbc / OdbcDataReader.cs
index b6e31ca10bf38322bd1d2739eb0c59a7dcf618dc..1359cfe681db013b8a32248ea137588f88d2efec 100644 (file)
@@ -340,10 +340,12 @@ namespace System.Data.Odbc
 
                [MonoTODO]
                [EditorBrowsableAttribute (EditorBrowsableState.Never)]
-               public 
+#if ONLY_1_1
+               public
+#endif
 #if NET_2_0
                new
-#endif // NET_2_0
+#endif
                IDataReader GetData (int ordinal)
                {
                        throw new NotImplementedException ();
@@ -705,7 +707,7 @@ namespace System.Data.Odbc
                                                        if (outsize < bufsize)
                                                                sb1.Append (System.Text.Encoding.Default.GetString(buffer,0,outsize));
                                                        else
-                                                               sb1.Append (System.Text.Encoding.Default.GetString(buffer,0,bufsize));
+                                                               sb1.Append (System.Text.Encoding.Default.GetString (buffer, 0, bufsize - 1));
                                                }
                                        } while (ret != OdbcReturn.NoData);
                                        DataValue = sb1.ToString ();
@@ -726,9 +728,12 @@ namespace System.Data.Odbc
                                case OdbcType.Time:
                                        OdbcTimestamp ts_data = new OdbcTimestamp();
                                        ret = libodbc.SQLGetData (hstmt, ColIndex, col.SqlCType, ref ts_data, 0, ref outsize);
-                                       if (outsize!=-1) // This means SQL_NULL_DATA 
+                                       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));
+                                                                      ts_data.minute,ts_data.second);
+                                               if (ts_data.fraction != 0)
+                                                       DataValue = ((DateTime) DataValue).AddTicks ((long)ts_data.fraction / 100);
+                                       }
                                        break;
                                case OdbcType.VarBinary :
                                case OdbcType.Image :
@@ -904,10 +909,10 @@ namespace System.Data.Odbc
                 {
                         OdbcReturn ret = OdbcReturn.Error;
                         byte [] buffer = new byte [255];
-                        int outsize = 0;
+                        short outsize = 0;
                         int val = 0;
-                        ret = libodbc.SQLColAttribute (hstmt, column, fieldId, 
-                                                       buffer, buffer.Length, 
+                        ret = libodbc.SQLColAttribute (hstmt, (short)column, fieldId, 
+                                                       buffer, (short)buffer.Length, 
                                                        ref outsize, ref val);
                         if (ret != OdbcReturn.Success && ret != OdbcReturn.SuccessWithInfo)
                                 throw new OdbcException (new OdbcError ("SQLColAttribute",
@@ -922,10 +927,10 @@ namespace System.Data.Odbc
                 {
                         OdbcReturn ret = OdbcReturn.Error;
                         byte [] buffer = new byte [255];
-                        int outsize = 0;
+                        short outsize = 0;
                         int val = 0;
-                        ret = libodbc.SQLColAttribute (hstmt, column, fieldId, 
-                                                       buffer, buffer.Length, 
+                        ret = libodbc.SQLColAttribute (hstmt, (short)column, fieldId, 
+                                                       buffer, (short)buffer.Length, 
                                                        ref outsize, ref val);
                         if (ret != OdbcReturn.Success && ret != OdbcReturn.SuccessWithInfo)
                                 throw new OdbcException (new OdbcError ("SQLColAttribute",
@@ -952,6 +957,8 @@ namespace System.Data.Odbc
                                } catch (OdbcException) {
                                }
                         }
+                       if (keys == null)
+                               return null;
                        keys.Sort ();
                        return (string []) keys.ToArray (typeof (string));
                 }
@@ -1073,28 +1080,6 @@ namespace System.Data.Odbc
                        return NextRow ();
                }
 
-#if NET_2_0
-                [MonoTODO]
-               public override object GetProviderSpecificValue (int i)
-                {
-                       throw new NotImplementedException ();
-                }
-                
-                [MonoTODO]
-               public override int GetProviderSpecificValues (object[] values)
-                {
-                       throw new NotImplementedException ();
-                }
-
-                [MonoTODO]
-               public override Type GetProviderSpecificFieldType (int i)
-                {
-                       throw new NotImplementedException ();
-                }
-                
-#endif // NET_2_0
-
-
                #endregion
        }
 }