diff options
Diffstat (limited to 'mcs/class/System.Data')
26 files changed, 86 insertions, 822 deletions
diff --git a/mcs/class/System.Data/Mono.Data.SqlExpressions/ChangeLog b/mcs/class/System.Data/Mono.Data.SqlExpressions/ChangeLog index f633f97c624..e4266e2d3cd 100644 --- a/mcs/class/System.Data/Mono.Data.SqlExpressions/ChangeLog +++ b/mcs/class/System.Data/Mono.Data.SqlExpressions/ChangeLog @@ -1,6 +1,3 @@ -2004-07-12 Umadevi S <sumadevi@novell.com> - * Tokenizer.cs - read an Int64 from the text instead of Int32. Resolves bug 61203 - 2004-06-17 Boris Kirzner <borisk@mainsoft.com> * Comparison.cs - use 'as' to avoid NullReferenceExeption in casting. diff --git a/mcs/class/System.Data/Mono.Data.SqlExpressions/Tokenizer.cs b/mcs/class/System.Data/Mono.Data.SqlExpressions/Tokenizer.cs index c3b4eb1faf8..a9b427d1bf0 100644 --- a/mcs/class/System.Data/Mono.Data.SqlExpressions/Tokenizer.cs +++ b/mcs/class/System.Data/Mono.Data.SqlExpressions/Tokenizer.cs @@ -122,7 +122,7 @@ namespace Mono.Data.SqlExpressions { string str = sb.ToString (); if (str.IndexOf(".") == -1) - return Int64.Parse (str); + return int.Parse (str); else return double.Parse (str); } diff --git a/mcs/class/System.Data/System.Data.Common/ChangeLog b/mcs/class/System.Data/System.Data.Common/ChangeLog index 6af8fca9b77..0db883a625e 100755 --- a/mcs/class/System.Data/System.Data.Common/ChangeLog +++ b/mcs/class/System.Data/System.Data.Common/ChangeLog @@ -1,11 +1,5 @@ -2004-07-21 Umadevi S <sumadevi@novell.com> - * DbDataRecord.cs - Fix for bug 58163. Return DBNull instead of null - -2004-07-07 Umadevi S <sumadevi@novell.com> - * DataContainer.cs :CheckedforNull before calling the relavant setmethods in each of the - SetItemForDataRecord method for the DateTimeClass - 2004-06-24 Atsushi Enomoto <atsushi@ximian.com> + * DataColumnMappingCollection.cs : fixed typo. * DbDataAdapter.cs : column mappings were not filled. diff --git a/mcs/class/System.Data/System.Data.Common/DataContainer.cs b/mcs/class/System.Data/System.Data.Common/DataContainer.cs index de0d64bc598..5b627d7d8ba 100644 --- a/mcs/class/System.Data/System.Data.Common/DataContainer.cs +++ b/mcs/class/System.Data/System.Data.Common/DataContainer.cs @@ -1098,8 +1098,8 @@ namespace System.Data.Common { // if exception thrown, it should be caught // in the caller method - if (!CheckAndSetNull(index,record,field)) - base.SetValue(index,record.GetDateTime(field)); + base.SetValue(index,record.GetDateTime(field)); + base.SetItemFromDataRecord(index,record,field); } internal override int CompareValues(int index1, int index2) diff --git a/mcs/class/System.Data/System.Data.Common/DbDataRecord.cs b/mcs/class/System.Data/System.Data.Common/DbDataRecord.cs index 69a2013f64d..0a6fa0e868d 100644 --- a/mcs/class/System.Data/System.Data.Common/DbDataRecord.cs +++ b/mcs/class/System.Data/System.Data.Common/DbDataRecord.cs @@ -340,7 +340,7 @@ namespace System.Data.Common { public bool IsDBNull (int i) { - return GetValue (i) == DBNull.Value; + return GetValue (i) == null; } #if NET_2_0 public virtual bool IsSetAsDefault (int i) diff --git a/mcs/class/System.Data/System.Data.Odbc/ChangeLog b/mcs/class/System.Data/System.Data.Odbc/ChangeLog index e633dabdd9d..d8581c1975b 100644 --- a/mcs/class/System.Data/System.Data.Odbc/ChangeLog +++ b/mcs/class/System.Data/System.Data.Odbc/ChangeLog @@ -1,47 +1,3 @@ -2004-08-31 Umadevi S (sumadevi@novell.com) - * OdbcDataReader.cs - Fixed Decimal parsing - - -2004-08-30 Umadevi S (sumadevi@novell.com) - * OdbcType.cs - removed inheritance from short. - -2004-08-27 Sureshkumar T (tsureshkumar@novell.com) - * OdbcDataReader.cs - fixed bug #63539 - TINYINT ODBC datatype is converted into System.Byte - -2004-08-26 Sureshkumar T (tsureshkumar@novell.com) - * OdbcDataReader.cs - Date & DateTime GetValue fixed. - GetBytes ordinal parameter passing fixed for BINARY in GetValue. - -2004-08-20 Sureshkumar T (tsureshkumar@novell.com) - * OdbcConnection.cs - correct handles are passed to OdbcError exception to trap the correct error - -2004-08-04 Umadevi S (sumadevi@novell.com) - * OdbcDataReader.cs - Fixed bug 61832 - Column names were not filled, due to which name based lookup of columns failed. - -2004-08-04 Umadevi S (sumadevi@novell.com) - * OdbcDataReader.cs - Fixed bug 61405 - Handling smallint column type. - -2004-07-30 Sureshkumar T (tsureshkumar@novell.com) - * OdbcCommand.cs: ExecuteNonQuery Closed statement handle to fix memory leak - * OdbcDataReader.cs: Closed statement handle to fix memory leak - Removed SQLState login in GetBytes coz OdbcError provides the same. - -2004-07-29 Umadevi S (sumadevi@novell.com) - * OdbcCommand.cs - Fixed bug 62046. ExecuteNonQuery implemented correctly - -2004-07-28 Umadevi S (sumadevi@novell.com) - * OdbcParameter.cs - fixed bug 61968. String values passed with quotes - -2004-07-07 Umadevi S (sumadevi@novell.com) - * OdbcConnection.cs - Allowed Close to be called multiple times - - Implementation of Dispose method - -2004-07-07 Umadevi S (sumadevi@novell.com) - * OdbcCommand.cs : fixed set method for Transaction - -2004-07-01 Sureshkumar T (tsureshkumar@novell.com) - * OdbcCommand.cs : fixed reader problem with ExecuteScalar - 2004-06-23 Sureshkumar T (tsureshkumar@novell.com) * OdbcConnection.cs: Fix: Moved env allocation to Open method. Disconnection & freeing handles are done in Close diff --git a/mcs/class/System.Data/System.Data.Odbc/OdbcCommand.cs b/mcs/class/System.Data/System.Data.Odbc/OdbcCommand.cs index 64c4fcfe661..fe242f3bf8f 100644 --- a/mcs/class/System.Data/System.Data.Odbc/OdbcCommand.cs +++ b/mcs/class/System.Data/System.Data.Odbc/OdbcCommand.cs @@ -223,14 +223,7 @@ namespace System.Data.Odbc return (IDbTransaction) Transaction;
}
set {
- if (value is OdbcTransaction) - { - Transaction = (OdbcTransaction)value; - } - else - { - throw new ArgumentException (); - } + throw new NotImplementedException ();
}
}
@@ -292,12 +285,6 @@ namespace System.Data.Odbc public int ExecuteNonQuery ()
{
- return ExecuteNonQuery (true); - }
-
- private int ExecuteNonQuery (bool freeHandle) - { - int records = 0; if (connection == null)
throw new InvalidOperationException ();
if (connection.State == ConnectionState.Closed)
@@ -305,29 +292,12 @@ namespace System.Data.Odbc // FIXME: a third check is mentioned in .NET docs
ExecSQL(CommandText);
- - // .NET documentation says that except for INSERT, UPDATE and - // DELETE where the return value is the number of rows affected - // for the rest of the commands the return value is -1. - if ((CommandText.ToUpper().IndexOf("UPDATE")!=-1) || - (CommandText.ToUpper().IndexOf("INSERT")!=-1) || - (CommandText.ToUpper().IndexOf("DELETE")!=-1)) { - - int numrows = 0; - OdbcReturn ret = libodbc.SQLRowCount(hstmt,ref numrows); - records = numrows; - } - else - records = -1; -
- if (freeHandle && !prepared) {
- OdbcReturn ret = libodbc.SQLFreeHandle( (ushort) OdbcHandleType.Stmt, hstmt);
- if ((ret!=OdbcReturn.Success) && (ret!=OdbcReturn.SuccessWithInfo))
- throw new OdbcException(new OdbcError("SQLFreeHandle",OdbcHandleType.Stmt,hstmt));
- } - return records;
- } - +
+// if (!prepared)
+// libodbc.SQLFreeHandle( (ushort) OdbcHandleType.Stmt, hstmt);
+ return 0;
+ }
+
public void Prepare()
{
OdbcReturn ret=libodbc.SQLAllocHandle(OdbcHandleType.Stmt, Connection.hDbc, ref hstmt);
@@ -360,7 +330,7 @@ namespace System.Data.Odbc public OdbcDataReader ExecuteReader (CommandBehavior behavior)
{
- ExecuteNonQuery(false);
+ ExecuteNonQuery();
dataReader=new OdbcDataReader(this,behavior);
return dataReader;
}
@@ -372,12 +342,11 @@ namespace System.Data.Odbc public object ExecuteScalar ()
{
- object val = null;
+ object val;
OdbcDataReader reader=ExecuteReader();
try
{
- if (reader.Read ())
- val=reader[0];
+ val=reader[0];
}
finally
{
diff --git a/mcs/class/System.Data/System.Data.Odbc/OdbcConnection.cs b/mcs/class/System.Data/System.Data.Odbc/OdbcConnection.cs index b40eb86c8d2..e6bd6ff0441 100644 --- a/mcs/class/System.Data/System.Data.Odbc/OdbcConnection.cs +++ b/mcs/class/System.Data/System.Data.Odbc/OdbcConnection.cs @@ -46,7 +46,6 @@ namespace System.Data.Odbc int connectionTimeout; internal OdbcTransaction transaction; IntPtr henv=IntPtr.Zero, hdbc=IntPtr.Zero; - bool disposed = false; #endregion @@ -198,25 +197,27 @@ namespace System.Data.Odbc // disconnect ret = libodbc.SQLDisconnect (hdbc); if ( (ret!=OdbcReturn.Success) && (ret!=OdbcReturn.SuccessWithInfo)) - throw new OdbcException (new OdbcError ("SQLDisconnect", OdbcHandleType.Dbc,hdbc)); + throw new OdbcException (new OdbcError ("SQLConnect", OdbcHandleType.Dbc,hdbc)); // free handles if (hdbc != IntPtr.Zero) { ret = libodbc.SQLFreeHandle ( (ushort) OdbcHandleType.Dbc, hdbc); if ( (ret!=OdbcReturn.Success) && (ret!=OdbcReturn.SuccessWithInfo)) - throw new OdbcException (new OdbcError ("SQLFreeHandle", OdbcHandleType.Dbc,hdbc)); + throw new OdbcException (new OdbcError ("SQLConnect", OdbcHandleType.Dbc,hdbc)); } hdbc = IntPtr.Zero; if (henv != IntPtr.Zero) { ret = libodbc.SQLFreeHandle ( (ushort) OdbcHandleType.Env, henv); if ( (ret!=OdbcReturn.Success) && (ret!=OdbcReturn.SuccessWithInfo)) - throw new OdbcException (new OdbcError ("SQLFreeHandle", OdbcHandleType.Env,henv)); + throw new OdbcException (new OdbcError ("SQLConnect", OdbcHandleType.Dbc,hdbc)); } henv = IntPtr.Zero; transaction = null; } + else + throw new InvalidOperationException (); } public OdbcCommand CreateCommand () @@ -230,23 +231,10 @@ namespace System.Data.Odbc throw new NotImplementedException (); } + [MonoTODO] protected override void Dispose (bool disposing) - { - if (!this.disposed) { - try - { - // release the native unmananged resources - this.Close(); - this.disposed = true; - } - finally - { - // call Dispose on the base class - base.Dispose(disposing); - } - } - } - + { + } [MonoTODO] object ICloneable.Clone () diff --git a/mcs/class/System.Data/System.Data.Odbc/OdbcDataReader.cs b/mcs/class/System.Data/System.Data.Odbc/OdbcDataReader.cs index 61b49d55481..394963734f0 100644 --- a/mcs/class/System.Data/System.Data.Odbc/OdbcDataReader.cs +++ b/mcs/class/System.Data/System.Data.Odbc/OdbcDataReader.cs @@ -167,8 +167,25 @@ namespace System.Data.Odbc return cols[ordinal]; } + private string GetSQLState (IntPtr hstmt, ushort recNo) + { + OdbcReturn ret = OdbcReturn.Error; + short bufLength=256, txtLength=0; + int nativeError = 1; + string sqlState = "", sqlMsg = ""; + byte [] msgtxtBuffer = new byte [bufLength]; + byte [] sqlStateBuffer = new byte [bufLength]; + ret = libodbc.SQLGetDiagRec (OdbcHandleType.Stmt, hstmt, recNo, + sqlStateBuffer, ref nativeError, msgtxtBuffer, + bufLength, ref txtLength); + sqlState = Encoding.Default.GetString (sqlStateBuffer).Replace ( + (char) 0, ' ').Trim (); + return sqlState; + } + public void Close () { + // libodbc.SQLFreeHandle((ushort) OdbcHandleType.Stmt, hstmt); OdbcReturn ret=libodbc.SQLCloseCursor(hstmt); if ((ret!=OdbcReturn.Success) && (ret!=OdbcReturn.SuccessWithInfo)) @@ -179,9 +196,6 @@ namespace System.Data.Odbc if ((behavior & CommandBehavior.CloseConnection)==CommandBehavior.CloseConnection) this.command.Connection.Close(); - ret = libodbc.SQLFreeHandle( (ushort) OdbcHandleType.Stmt, hstmt);
- if ((ret!=OdbcReturn.Success) && (ret!=OdbcReturn.SuccessWithInfo)) - throw new OdbcException(new OdbcError("SQLFreeHandle",OdbcHandleType.Stmt,hstmt)); } ~OdbcDataReader () @@ -217,10 +231,6 @@ namespace System.Data.Odbc if ( (ret != OdbcReturn.Success) && (ret != OdbcReturn.SuccessWithInfo)) throw new OdbcException (new OdbcError ("SQLGetData", OdbcHandleType.Stmt, hstmt)); - OdbcError odbcErr = null; - if ( (ret == OdbcReturn.SuccessWithInfo)) - odbcErr = new OdbcError ("SQLGetData", OdbcHandleType.Stmt, hstmt); - if (buffer == null) return outsize; //if buffer is null,return length of the field @@ -231,10 +241,11 @@ namespace System.Data.Odbc copyBuffer = false; returnVal = -1; } else { - string sqlstate = odbcErr.SQLState; + string sqlstate = GetSQLState (hstmt, 1); //SQLState: String Data, Right truncated if (sqlstate != libodbc.SQLSTATE_RIGHT_TRUNC) - throw new OdbcException ( odbcErr); + throw new OdbcException (new OdbcError ("SQLGetData", + OdbcHandleType.Stmt, hstmt)); copyBuffer = true; } } else { @@ -389,6 +400,7 @@ namespace System.Data.Odbc for (int i = 0; i < cols.Length; i += 1 ) { OdbcColumn col=GetColumn(i); + //Console.WriteLine("{0}:{1}:{2}",col.ColumnName,col.DataType,col.OdbcType); schemaRow = dataTableSchema.NewRow (); dataTableSchema.Rows.Add (schemaRow); @@ -473,23 +485,14 @@ namespace System.Data.Odbc bufsize=50; buffer=new byte[bufsize]; // According to sqlext.h, use SQL_CHAR for decimal ret=libodbc.SQLGetData(hstmt, ColIndex, OdbcType.Char, buffer, bufsize, ref outsize); - byte[] temp = new byte[outsize]; - for (int i=0;i<outsize;i++) - temp[i]=buffer[i]; - if (outsize!=-1) - DataValue=Decimal.Parse(System.Text.Encoding.Default.GetString(temp)); + DataValue=Decimal.Parse(System.Text.Encoding.Default.GetString(buffer)); break; case OdbcType.TinyInt: short short_data=0; ret=libodbc.SQLGetData(hstmt, ColIndex, OdbcType.TinyInt, ref short_data, 0, ref outsize); - DataValue = System.Convert.ToByte (short_data); + DataValue=short_data; break; - case OdbcType.SmallInt: - short sint_data=0; - ret=libodbc.SQLGetData(hstmt, ColIndex, OdbcType.SmallInt, ref sint_data, 0, ref outsize); - DataValue=sint_data; - break; case OdbcType.Int: int int_data=0; ret=libodbc.SQLGetData(hstmt, ColIndex, OdbcType.Int, ref int_data, 0, ref outsize); @@ -521,17 +524,8 @@ namespace System.Data.Odbc break; case OdbcType.Timestamp: case OdbcType.DateTime: - case OdbcType.Date: - case OdbcType.Time: OdbcTimestamp ts_data=new OdbcTimestamp(); - if (col.OdbcType == OdbcType.Timestamp) - ret=libodbc.SQLGetData(hstmt, ColIndex, OdbcType.Timestamp, ref ts_data, 0, ref outsize); - else if (col.OdbcType == OdbcType.DateTime) - ret=libodbc.SQLGetData(hstmt, ColIndex, OdbcType.DateTime, ref ts_data, 0, ref outsize); - else if (col.OdbcType == OdbcType.Date) - ret=libodbc.SQLGetData(hstmt, ColIndex, OdbcType.Date, ref ts_data, 0, ref outsize); - else // FIXME: how to get TIME datatype ?? - ret=libodbc.SQLGetData(hstmt, ColIndex, OdbcType.DateTime, ref ts_data, 0, ref outsize); + ret=libodbc.SQLGetData(hstmt, ColIndex, OdbcType.DateTime, 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)); @@ -540,11 +534,12 @@ namespace System.Data.Odbc case OdbcType.Image : bufsize = col.MaxLength + 1; buffer = new byte [bufsize]; - long read = GetBytes (ordinal, 0, buffer, 0, bufsize); + long read = GetBytes (ColIndex, 0, buffer, 0, bufsize); ret = OdbcReturn.Success; DataValue = buffer; break; default: + //Console.WriteLine("Fetching unsupported data type as string: "+col.OdbcType.ToString()); bufsize=255; buffer=new byte[bufsize]; ret=libodbc.SQLGetData(hstmt, ColIndex, OdbcType.Char, buffer, bufsize, ref outsize); @@ -617,8 +612,6 @@ namespace System.Data.Odbc currentRow=-1; else currentRow++; - GetSchemaTable(); - // Clear cached values from last record foreach (OdbcColumn col in cols) { diff --git a/mcs/class/System.Data/System.Data.Odbc/OdbcParameter.cs b/mcs/class/System.Data/System.Data.Odbc/OdbcParameter.cs index 11153197ca7..51df821d86f 100644 --- a/mcs/class/System.Data/System.Data.Odbc/OdbcParameter.cs +++ b/mcs/class/System.Data/System.Data.Odbc/OdbcParameter.cs @@ -261,9 +261,6 @@ namespace System.Data.Odbc string paramValueString = ParamValue.ToString();
// Treat everything else as a string
// Init string buffer
- if (ParamValue is String) - paramValueString = "\'"+paramValueString+"\'"; - if (buffer == null || buffer.Length < ((size > 20) ? size : 20))
buffer = new byte[(size > 20) ? size : 20];
else
diff --git a/mcs/class/System.Data/System.Data.Odbc/OdbcType.cs b/mcs/class/System.Data/System.Data.Odbc/OdbcType.cs index 6e7c3169bee..fed8035a7e6 100644 --- a/mcs/class/System.Data/System.Data.Odbc/OdbcType.cs +++ b/mcs/class/System.Data/System.Data.Odbc/OdbcType.cs @@ -51,7 +51,7 @@ namespace System.Data.Odbc //#define SQL_INTERVAL 10
// could map to SmallDateTime?
- public enum OdbcType + public enum OdbcType : short
{
BigInt=-5, // SQL_BIGINT
Binary=-2, // SQL_BINARY
diff --git a/mcs/class/System.Data/System.Data.SqlClient/ChangeLog b/mcs/class/System.Data/System.Data.SqlClient/ChangeLog index 8cbc2916c38..5576c7f7c6b 100755 --- a/mcs/class/System.Data/System.Data.SqlClient/ChangeLog +++ b/mcs/class/System.Data/System.Data.SqlClient/ChangeLog @@ -1,10 +1,6 @@ -2004-09-02 Umadevi S <sumadevi@novell.com> - * SqlCommand.cs - ExecuteNonQuery to return -1 incase of executing a storedprocedure - - -2004-08-12 Sureshkumar T <tsureshkumar@novell.com> - * SqlDataReader.cs - In Close method, the remaining resultsets are drained - out, to read output parameters & to avoid stream overlap +2004-06-30 Umadevi S <sumadevi@novell.com> + * SqlCommand.cs : In the Execute Method the commandbehavior parameters were ignored correct +these 2004-06-22 Atsushi Enomoto <atsushi@ximian.com> diff --git a/mcs/class/System.Data/System.Data.SqlClient/SqlCommand.cs b/mcs/class/System.Data/System.Data.SqlClient/SqlCommand.cs index a5ada9fd053..21978c14cf2 100644 --- a/mcs/class/System.Data/System.Data.SqlClient/SqlCommand.cs +++ b/mcs/class/System.Data/System.Data.SqlClient/SqlCommand.cs @@ -268,8 +268,8 @@ namespace System.Data.SqlClient { { TdsMetaParameterCollection parms = Parameters.MetaParameters; if (preparedStatement == null) { - bool schemaOnly = ((CommandBehavior & CommandBehavior.SchemaOnly) > 0); - bool keyInfo = ((CommandBehavior & CommandBehavior.KeyInfo) > 0); + bool schemaOnly = ((behavior & CommandBehavior.SchemaOnly) > 0); + bool keyInfo = ((behavior & CommandBehavior.KeyInfo) > 0); StringBuilder sql1 = new StringBuilder (); StringBuilder sql2 = new StringBuilder (); @@ -310,19 +310,16 @@ namespace System.Data.SqlClient { try { Execute (CommandBehavior.Default, false); - if (commandType == CommandType.StoredProcedure) - result = -1; - else { - // .NET documentation says that except for INSERT, UPDATE and - // DELETE where the return value is the number of rows affected - // for the rest of the commands the return value is -1. - if ((CommandText.ToUpper().IndexOf("UPDATE")!=-1) || - (CommandText.ToUpper().IndexOf("INSERT")!=-1) || - (CommandText.ToUpper().IndexOf("DELETE")!=-1)) + // .NET documentation says that except for INSERT, UPDATE and + // DELETE where the return value is the number of rows affected + // for the rest of the commands the return value is -1. + if ((CommandText.ToUpper().IndexOf("UPDATE")!=-1) || + (CommandText.ToUpper().IndexOf("INSERT")!=-1) || + (CommandText.ToUpper().IndexOf("DELETE")!=-1)) result = Connection.Tds.RecordsAffected; - else - result = -1; - } + else + result = -1; + } catch (TdsTimeoutException e) { throw SqlException.FromTdsInternalException ((TdsInternalException) e); diff --git a/mcs/class/System.Data/System.Data.SqlClient/SqlDataReader.cs b/mcs/class/System.Data/System.Data.SqlClient/SqlDataReader.cs index abe23c3aebf..52b6a0a589a 100644 --- a/mcs/class/System.Data/System.Data.SqlClient/SqlDataReader.cs +++ b/mcs/class/System.Data/System.Data.SqlClient/SqlDataReader.cs @@ -131,9 +131,6 @@ namespace System.Data.SqlClient { public void Close () { - // skip to end & read output parameters - while (NextResult ()) - ; isClosed = true; command.Connection.DataReader = null; command.CloseDataReader (moreResults); diff --git a/mcs/class/System.Data/System.Data/ChangeLog b/mcs/class/System.Data/System.Data/ChangeLog index 78cc45ac101..5477819e402 100644 --- a/mcs/class/System.Data/System.Data/ChangeLog +++ b/mcs/class/System.Data/System.Data/ChangeLog @@ -1,18 +1,3 @@ -2004-08-06 Atsushi Enomoto <atsushi@ximian.com> - - * DataSet.cs : DataSet's ExtendedProperties were not XmlConverted. - -2004-08-05 Atsushi Enomoto <atsushi@ximian.com> - - * XmlConstants.cs : Added constants for "msprop" support. - * DataSet.cs : ExtendedProperties should be written in the schema. - This fixes bug #61233. - -2004-07-27 Atsushi Enomoto <atsushi@ximian.com> - - * DataSet.cs : on serialization to XmlWriter, XmlConvert should be - used. There were also some culture dependency problems to write int. - 2004-06-27 Atsushi Enomoto <atsushi@ximian.com> * XmlDataInferenceLoader.cs : It was not always filling relation diff --git a/mcs/class/System.Data/System.Data/DataSet.cs b/mcs/class/System.Data/System.Data/DataSet.cs index 8ac4d34836b..34f9f8f4c80 100644 --- a/mcs/class/System.Data/System.Data/DataSet.cs +++ b/mcs/class/System.Data/System.Data/DataSet.cs @@ -1270,7 +1270,7 @@ namespace System.Data { private void WriteColumnAsAttribute (XmlWriter writer, XmlWriteMode mode, DataColumn col, DataRow row, DataRowVersion version) { - WriteAttributeString (writer, mode, col.Namespace, col.Prefix, XmlConvert.EncodeLocalName (col.ColumnName), WriteObjectXml (row[col, version])); + WriteAttributeString (writer, mode, col.Namespace, col.Prefix, XmlConvert.EncodeLocalName (col.ColumnName), row[col, version].ToString ()); } private void WriteTableElement (XmlWriter writer, XmlWriteMode mode, DataTable table, DataRow row, DataRowVersion version) @@ -1282,7 +1282,7 @@ namespace System.Data { if (mode == XmlWriteMode.DiffGram) { WriteAttributeString (writer, mode, XmlConstants.DiffgrNamespace, XmlConstants.DiffgrPrefix, "id", table.TableName + (row.XmlRowID + 1)); - WriteAttributeString (writer, mode, XmlConstants.MsdataNamespace, XmlConstants.MsdataPrefix, "rowOrder", XmlConvert.ToString (row.XmlRowID)); + WriteAttributeString (writer, mode, XmlConstants.MsdataNamespace, XmlConstants.MsdataPrefix, "rowOrder", row.XmlRowID.ToString()); string modeName = null; if (row.RowState == DataRowState.Modified) modeName = "modified"; @@ -1390,8 +1390,6 @@ namespace System.Data { nsmgr.AddNamespace (XmlConstants.TnsPrefix, Namespace); nsmgr.AddNamespace (String.Empty, Namespace); } - if (CheckExtendedPropertyExists ()) - nsmgr.AddNamespace (XmlConstants.MspropPrefix, XmlConstants.MspropNamespace); if (atts.Count > 0) schema.UnhandledAttributes = atts.ToArray (typeof (XmlAttribute)) as XmlAttribute []; @@ -1418,8 +1416,6 @@ namespace System.Data { elem.UnhandledAttributes = atts.ToArray (typeof (XmlAttribute)) as XmlAttribute []; - AddExtendedPropertyAttributes (elem, ExtendedProperties, doc); - XmlSchemaComplexType complex = new XmlSchemaComplexType (); elem.SchemaType = complex; @@ -1450,7 +1446,7 @@ namespace System.Data { schema.Items.Add (elem); - AddConstraintsToSchema (elem, constraintPrefix, tables, relations, doc); + AddConstraintsToSchema (elem, constraintPrefix, tables, relations); foreach (string prefix in nsmgr) { string ns = nsmgr.LookupNamespace (nsmgr.NameTable.Get (prefix)); if (prefix != "xmlns" && prefix != "xml" && ns != null && ns != String.Empty) @@ -1459,48 +1455,29 @@ namespace System.Data { return schema; } - private bool CheckExtendedPropertyExists () - { - if (ExtendedProperties.Count > 0) - return true; - foreach (DataTable dt in Tables) { - if (dt.ExtendedProperties.Count > 0) - return true; - foreach (DataColumn col in dt.Columns) - if (col.ExtendedProperties.Count > 0) - return true; - foreach (Constraint c in dt.Constraints) - if (c.ExtendedProperties.Count > 0) - return true; - } - foreach (DataRelation rel in Relations) - if (rel.ExtendedProperties.Count > 0) - return true; - return false; - } - // Add all constraints in all tables to the schema. - private void AddConstraintsToSchema (XmlSchemaElement elem, string constraintPrefix, DataTableCollection tables, DataRelationCollection relations, XmlDocument doc) + private void AddConstraintsToSchema (XmlSchemaElement elem, string constraintPrefix, DataTableCollection tables, DataRelationCollection relations) { // first add all unique constraints. - Hashtable uniqueNames = AddUniqueConstraints (elem, constraintPrefix, tables, doc); + Hashtable uniqueNames = AddUniqueConstraints (elem, constraintPrefix, tables); // Add all foriegn key constraints. - AddForeignKeys (uniqueNames, elem, constraintPrefix, relations, doc); + AddForeignKeys (uniqueNames, elem, constraintPrefix, relations); } // Add unique constaraints to the schema. // return hashtable with the names of all XmlSchemaUnique elements we created. - private Hashtable AddUniqueConstraints (XmlSchemaElement elem, string constraintPrefix, DataTableCollection tables, XmlDocument doc) + private Hashtable AddUniqueConstraints (XmlSchemaElement elem, string constraintPrefix, DataTableCollection tables) { + XmlDocument doc = new XmlDocument(); Hashtable uniqueNames = new Hashtable(); foreach (DataTable table in tables) { - foreach (Constraint constraint in table.Constraints) { + foreach (Constraint constaint in table.Constraints) { - if (constraint is UniqueConstraint) { + if (constaint is UniqueConstraint) { ArrayList attrs = new ArrayList (); XmlAttribute attrib; - UniqueConstraint uqConst = (UniqueConstraint) constraint; + UniqueConstraint uqConst = (UniqueConstraint)constaint; XmlSchemaUnique uniq = new XmlSchemaUnique (); // if column of the constraint is hidden do not write the constraint. @@ -1543,8 +1520,6 @@ namespace System.Data { uniq.Fields.Add(field); } - AddExtendedPropertyAttributes (uniq, constraint.ExtendedProperties, doc); - elem.Constraints.Add (uniq); uniqueNames.Add (uniq.Name, null); } @@ -1554,10 +1529,11 @@ namespace System.Data { } // Add the foriegn keys to the schema. - private void AddForeignKeys (Hashtable uniqueNames, XmlSchemaElement elem, string constraintPrefix, DataRelationCollection relations, XmlDocument doc) + private void AddForeignKeys (Hashtable uniqueNames, XmlSchemaElement elem, string constraintPrefix, DataRelationCollection relations) { if (relations == null) return; + XmlDocument doc = new XmlDocument(); foreach (DataRelation rel in relations) { if (rel.ParentKeyConstraint == null || rel.ChildKeyConstraint == null) @@ -1609,10 +1585,7 @@ namespace System.Data { field.XPath = constraintPrefix+column.ColumnName; keyRef.Fields.Add(field); } - keyRef.UnhandledAttributes = (XmlAttribute[])attrs.ToArray (typeof (XmlAttribute)); - AddExtendedPropertyAttributes (keyRef, rel.ExtendedProperties, doc); - elem.Constraints.Add (keyRef); } } @@ -1645,7 +1618,7 @@ namespace System.Data { // add ordinal attribute xlmAttrs[1] = doc.CreateAttribute (XmlConstants.MsdataPrefix, XmlConstants.Ordinal, XmlConstants.MsdataNamespace); - xlmAttrs[1].Value = XmlConvert.ToString (simple.Ordinal); + xlmAttrs[1].Value = simple.Ordinal.ToString(); simpleContent.UnhandledAttributes = xlmAttrs; @@ -1682,12 +1655,12 @@ namespace System.Data { if (col.AutoIncrementSeed != 0) { xattr = doc.CreateAttribute (XmlConstants.MsdataPrefix, XmlConstants.AutoIncrementSeed, XmlConstants.MsdataNamespace); - xattr.Value = XmlConvert.ToString (col.AutoIncrementSeed); + xattr.Value = col.AutoIncrementSeed.ToString(); xattrs.Add (xattr); } if (col.DefaultValue.ToString () != String.Empty) - colElem.DefaultValue = WriteObjectXml (col.DefaultValue); + colElem.DefaultValue = col.DefaultValue.ToString (); if (col.MaxLength < 0) colElem.SchemaTypeName = MapType (col.DataType); @@ -1714,7 +1687,6 @@ namespace System.Data { } colElem.UnhandledAttributes = (XmlAttribute[])xattrs.ToArray(typeof (XmlAttribute)); - AddExtendedPropertyAttributes (colElem, col.ExtendedProperties, doc); seq.Items.Add (colElem); } @@ -1754,33 +1726,12 @@ namespace System.Data { schemaToAdd.Namespaces.Add (prefix, col.Namespace); } att.SchemaTypeName = MapType (col.DataType); - // FIXME: what happens if extended properties are set on attribute columns?? schemaAttributes.Add (att); } - AddExtendedPropertyAttributes (elem, table.ExtendedProperties, doc); - return elem; } - private void AddExtendedPropertyAttributes (XmlSchemaAnnotated xsobj, PropertyCollection props, XmlDocument doc) - { - ArrayList attList = new ArrayList (); - XmlAttribute xmlAttr; - - if (xsobj.UnhandledAttributes != null) - attList.AddRange (xsobj.UnhandledAttributes); - - // add extended properties to xs:element - foreach (DictionaryEntry de in props) { - xmlAttr = doc.CreateAttribute (XmlConstants.MspropPrefix, XmlConvert.EncodeName (de.Key.ToString ()), XmlConstants.MspropNamespace); - xmlAttr.Value = de.Value != null ? WriteObjectXml (de.Value) : String.Empty; - attList.Add (xmlAttr); - } - if (attList.Count > 0) - xsobj.UnhandledAttributes = attList.ToArray (typeof (XmlAttribute)) as XmlAttribute []; - } - private string SafeNS (string ns) { return ns != null ? ns : String.Empty; diff --git a/mcs/class/System.Data/System.Data/XmlConstants.cs b/mcs/class/System.Data/System.Data/XmlConstants.cs index 1d459157606..b50a80bc6d5 100755 --- a/mcs/class/System.Data/System.Data/XmlConstants.cs +++ b/mcs/class/System.Data/System.Data/XmlConstants.cs @@ -83,8 +83,6 @@ internal class XmlConstants //ms schema objects public const string MsdataPrefix = "msdata"; public const string MsdataNamespace = "urn:schemas-microsoft-com:xml-msdata"; - public const string MspropPrefix = "msprop"; - public const string MspropNamespace = "urn:schemas-microsoft-com:xml-msprop"; public const string DiffgrPrefix = "diffgr"; public const string DiffgrNamespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; public const string TnsPrefix = "mstns"; diff --git a/mcs/class/System.Data/Test/ChangeLog b/mcs/class/System.Data/Test/ChangeLog index 65c8719353a..49630c2d5d8 100644 --- a/mcs/class/System.Data/Test/ChangeLog +++ b/mcs/class/System.Data/Test/ChangeLog @@ -1,13 +1,3 @@ -2004-08-26 Sureshkumar T <TSureshkumar@novell.com> - * MySqlTestBed.cs - Added few more fields for DateTime testing - -2004-08-13 Umadevi S <sumadevi@novell.com> - * Added standalone nunit testcases for datacontainer class. - * Currently will use MSSQL server - * New File - MSSqlTestBed.cs - Base class for MSSql testing - (similar to the mysqltestbed) - 2004-06-16 Sureshkumar T <TSureshkumar@novell.com> * Added standalone NUnit test cases for MySql db related tests. * Created sub-directory for System.Data.Odbc diff --git a/mcs/class/System.Data/Test/MSSqlTestBed.cs b/mcs/class/System.Data/Test/MSSqlTestBed.cs deleted file mode 100644 index bb2ed3bd160..00000000000 --- a/mcs/class/System.Data/Test/MSSqlTestBed.cs +++ /dev/null @@ -1,100 +0,0 @@ -// -// MSSqlTestBed.cs : This is base class which manages the connections to -// MSSql database. This serves as a base class for all -// MSSql database dependant tests. -// -// To run : -// -// * compile using following command -// mcs /r:System.Data.dll,nunit.framework.dll /t:library /debug -// /out:MSSqlTestBed.dll MSSqlTestBed.cs System.Data.Common/*.cs -// * To run the tests -// mono /usr/local/bin/nunit-console.exe MSSqlTestBed.dll -// -// Author: -// Umadevi S (sumadevi@novell.com) -// -// Copyright (c) 2004 Novell Inc., and the individuals listed -// on the ChangeLog entries. -// -// 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. -// - -using System; -using System.Data; -using System.Data.Common; -using System.Data.SqlClient; -using System.Collections.Specialized; - -namespace MonoTests.System.Data -{ - public class MSSqlTestClient - { - #region protected members - protected string connectionString = null; - protected SqlConnection conn = null; - protected bool isConnAlive = false; - #endregion - - public MSSqlTestClient () - { - connectionString = - "Server=164.99.168.131;" + - "Database=Northwind;" + - "User ID=sa;" + - "Password=novell"; - conn = new SqlConnection(connectionString); - } - - protected void OpenConnection () - { - conn.ConnectionString = connectionString; - conn.Open (); - // run tests only if the connection is open, - // otherwise make it fail, to setup with correct - // database settings - if (conn != null && conn.State != ConnectionState.Closed) - isConnAlive = true; - } - - protected void CloseConnection () - { - if (conn != null && conn.State != ConnectionState.Closed) { - conn.Close (); - isConnAlive = false; - } - } - - internal void ExecuteQuery (string query) - { - SqlCommand cmd = new SqlCommand (); - cmd.Connection = conn; - cmd.CommandText = query; - try { - int recordsAff = cmd.ExecuteNonQuery (); - } catch (Exception e) { - Console.WriteLine("exception"); - Console.WriteLine(e.StackTrace); - } - } - - - } -} diff --git a/mcs/class/System.Data/Test/MySqlTestBed.cs b/mcs/class/System.Data/Test/MySqlTestBed.cs index 1f8fef70c89..a923c0d326d 100644 --- a/mcs/class/System.Data/Test/MySqlTestBed.cs +++ b/mcs/class/System.Data/Test/MySqlTestBed.cs @@ -95,26 +95,23 @@ namespace MonoTests.System.Data "pk_tint TINYINT NOT NULL PRIMARY KEY," + "col_char CHAR(20)," + "col_int INT," + - "col_blob TINYBLOB," + - "col_datetime DATETIME," + - "col_date DATE," + - "col_time TIME" + + "col_blob TINYBLOB" + ");"; ExecuteQuery (createQuery); createQuery = "INSERT INTO test VALUES (1, 'mono test" + - "#1', 255, 127123645917568585638457243856234985, '2004-08-22', '2004-08-22', '12:00:00' );" ; + "#1', 255, 127123645917568585638457243856234985 );" ; ExecuteQuery (createQuery); createQuery = "INSERT INTO test VALUES (2, 'mono test" + - "#2', 256, NULL, NULL, NULL, NULL );"; + "#2', 256, NULL );" ; ExecuteQuery (createQuery); createQuery = "INSERT INTO test VALUES (3, 'mono test" + - "#3', 257 , 127123645917568585638457243856234985, '2004-08-22', '2004-08-22', '12:00:00');" ; + "#3', 257 , 127123645917568585638457243856234985);" ; ExecuteQuery (createQuery); createQuery = "INSERT INTO test VALUES (4, 'mono test" + - "#4', 258 , 127123645917568585638457243856234985, '2004-08-22', '2004-08-22', '12:00:00');" ; + "#4', 258 , 127123645917568585638457243856234985);" ; ExecuteQuery (createQuery); createQuery = "INSERT INTO test VALUES (5, 'mono test" + - "#5', 259, 127123645917568585638457243856234985, '2004-08-22', '2004-08-22', '12:00:00' );" ; + "#5', 259, 127123645917568585638457243856234985 );" ; ExecuteQuery (createQuery); } diff --git a/mcs/class/System.Data/Test/System.Data.Common/ChangeLog b/mcs/class/System.Data/Test/System.Data.Common/ChangeLog index 351489466c7..af4575be732 100644 --- a/mcs/class/System.Data/Test/System.Data.Common/ChangeLog +++ b/mcs/class/System.Data/Test/System.Data.Common/ChangeLog @@ -1,6 +1,3 @@ -2004-08-13 Umadevi S <sumadevi@novell.com> - * Added File DataContainerTest - 2004-06-10 Umadevi S <sumadevi@novell.com> * Corrected GetTableMappingBySchemaAction for DataTableMappingCollectionTest diff --git a/mcs/class/System.Data/Test/System.Data.Common/DataContainerTest.cs b/mcs/class/System.Data/Test/System.Data.Common/DataContainerTest.cs deleted file mode 100644 index 32e6cfd878c..00000000000 --- a/mcs/class/System.Data/Test/System.Data.Common/DataContainerTest.cs +++ /dev/null @@ -1,104 +0,0 @@ -//
-// DataContainerTest.cs - NUnit Test Cases for testing the
-// DataContainer class
-// Author:
-// Umadevi S (sumadevi@novell.com)
-//
-// Copyright (c) 2004 Novell Inc., and the individuals listed
-// on the ChangeLog entries.
-//
-// 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.
-//
-
-using System;
-using System.Data;
-using System.Data.Common; -using System.Data.SqlClient;
-
-using NUnit.Framework;
-
-namespace MonoTests.System.Data.Common
-{
-
- [TestFixture]
- public class DataContainerTest : MSSqlTestClient {
-
- [SetUp]
- public void GetReady () {
- OpenConnection ();
- CreateTestSetup (); // create test database & tables
- }
-
- [TearDown]
- public void Clean () {
- CleanTestSetup (); // clean test database
- CloseConnection ();
- } - - private void CreateTestSetup() - { - if (!isConnAlive) - return ; - // Create test database & tables - string createQuery = "DROP TABLE datetimetest;" ; - ExecuteQuery (createQuery); - createQuery = "CREATE TABLE datetimetest (" + - "col_char CHAR(20)," + - "col_date DATETIME );"; - ExecuteQuery (createQuery); - createQuery = "INSERT INTO datetimetest VALUES ('one', '4/12/2004 4:59:00');" ; - ExecuteQuery (createQuery); - createQuery = "INSERT INTO datetimetest VALUES ('two',null);" ; - ExecuteQuery (createQuery); - createQuery = "INSERT INTO datetimetest (col_char) VALUES ('three');" ; - ExecuteQuery (createQuery); - - - } - - private void CleanTestSetup() - { - if (!isConnAlive) - return; - // delete test database - string dropQuery = "DROP table datetimetest"; - ExecuteQuery(dropQuery); - - } -
-
- [Test]
- public void DateTimeTest () {
- try { - - SqlDataAdapter myadapter = new SqlDataAdapter("select * from datetimetest;",conn); - - DataTable dt = new DataTable(); - myadapter.Fill(dt); - Assertion.AssertEquals ("Row count must be three", 3, dt.Rows.Count ); - }
- - finally { // try/catch is necessary to gracefully close connections
- CleanTestSetup (); // clean test database
- CloseConnection ();
- }
- }
- }
-}
diff --git a/mcs/class/System.Data/Test/System.Data.Odbc/ChangeLog b/mcs/class/System.Data/Test/System.Data.Odbc/ChangeLog index 7ecb34c9d29..bd7b77d4f19 100644 --- a/mcs/class/System.Data/Test/System.Data.Odbc/ChangeLog +++ b/mcs/class/System.Data/Test/System.Data.Odbc/ChangeLog @@ -1,24 +1,3 @@ -2004-08-31 Umadevi S <sumadevi@novell.com> - * OdbcDataReaderTest.cs - Added a test for Numeric Type - -2004-08-27 Sureshkumar T <tsureshkumar@novell.com> - * OdbcDataReaderTest.cs - Added a test for TinyInt - -2004-08-26 Sureshkumar T <tsureshkumar@novell.com> - * OdbcDataReaderTest.cs - Added a test for DateTime - GetDateTimeTest - * OdbcCommandTest.cs - Syntax Error Fix - -2004-07-29 Umadevi S <sumadevi@novell.com> - * OdbcCommandTest.cs - Added testcase for bug 62046. ExecuteNonQuery - -2004-07-28 Umadevi S <sumadevi@novell.com> - * OdbcCommandTest.cs - Added testcase for bug 61968. String values passed with quotes - -2004-07-01 Sureshkumar T <tsureshkumar@novell.com> - * Added test case for OdbcCommand.ExecuteScalar Method - * New files: - OdbcCommandTest.cs - test suite for OdbcCommand class. - 2004-06-23 Sureshkumar T <TSureshkumar@novell.com> * Added test to check whether the OdbcConnection.Close method closes all the handles. diff --git a/mcs/class/System.Data/Test/System.Data.Odbc/OdbcCommandTest.cs b/mcs/class/System.Data/Test/System.Data.Odbc/OdbcCommandTest.cs deleted file mode 100644 index f46cf29c6c7..00000000000 --- a/mcs/class/System.Data/Test/System.Data.Odbc/OdbcCommandTest.cs +++ /dev/null @@ -1,113 +0,0 @@ -//
-// OdbcCommandTest.cs - NUnit Test Cases for testing the
-// OdbcCommand class
-//
-// Authors:
-// Sureshkumar T (TSureshkumar@novell.com)
-// Umadevi S (sumadevi@novell.com)
-//
-// Copyright (c) 2004 Novell Inc., and the individuals listed
-// on the ChangeLog entries.
-//
-// 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.
-//
-
-
-using System;
-using System.Data;
-using System.Data.Odbc;
-
-using NUnit.Framework;
-
-namespace MonoTests.System.Data.Odbc
-{
-
- [TestFixture]
- public class OdbcCommandTest : MySqlOdbcBaseClient
- {
-
- [SetUp]
- public void GetReady () {
- OpenConnection ();
- CreateTestSetup (); // create database & test tables
- }
-
- [TearDown]
- public void Clean () {
- CleanTestSetup (); // clean test database;
- CloseConnection ();
- }
-
- /// <summary>
- /// Test Execute Scalar Method
- /// </summary>
- [Test]
- public void ExecuteScalarTest ()
- {
- OdbcCommand cmd = conn.CreateCommand ();
- string query = "select count(*) from test order by col_int;";
- cmd.CommandText = query;
- object objCount = cmd.ExecuteScalar ();
- Assertion.AssertEquals( "ExecuteScalar does not return int type", 5, Convert.ToInt32(objCount));
- }
-
- /// <summary>
- /// Test String parameters to ODBC Command
- /// </summary>
- [Test]
- public void ExecuteStringParameterTest()
- {
-
- OdbcCommand dbcmd = new OdbcCommand();
- dbcmd.Connection = conn;
- dbcmd.CommandType = CommandType.Text;
- dbcmd.CommandText = "select count(*) from test where col_char=?;";
- string colvalue = "mono test#1";
- dbcmd.Parameters.Add("@un",colvalue);
- Object obj = dbcmd.ExecuteScalar();
- Assertion.AssertEquals( "String parameter not passed correctly",1,Convert.ToInt32(obj));
-
-
- }
-
- /// <summary>
- /// Test ExecuteNonQuery
- /// </summary>
- [Test]
- public void ExecuteNonQueryTest ()
- {
-
- OdbcCommand dbcmd = new OdbcCommand();
- dbcmd.Connection = conn;
- dbcmd.CommandType = CommandType.Text;
- dbcmd.CommandText = "select count(*) from test where col_char=?;";
- string colvalue = "mono test";
- dbcmd.Parameters.Add("@un",colvalue);
- int ret = dbcmd.ExecuteNonQuery();
- Assertion.AssertEquals( "ExecuteNonQuery not working",-1, ret);
- dbcmd = new OdbcCommand();
- dbcmd.Connection = conn;
- dbcmd.CommandType = CommandType.Text;
- dbcmd.CommandText = "delete from test where (col_int >257);";
- ret = dbcmd.ExecuteNonQuery();
- Assertion.AssertEquals("ExecuteNonQuery not working", 2, ret);
- }
-
-}
diff --git a/mcs/class/System.Data/Test/System.Data.Odbc/OdbcDataReaderTest.cs b/mcs/class/System.Data/Test/System.Data.Odbc/OdbcDataReaderTest.cs index b8ceeafbbbb..0017b818681 100644 --- a/mcs/class/System.Data/Test/System.Data.Odbc/OdbcDataReaderTest.cs +++ b/mcs/class/System.Data/Test/System.Data.Odbc/OdbcDataReaderTest.cs @@ -231,106 +231,5 @@ namespace MonoTests.System.Data.Odbc CloseConnection ();
}
}
-
- [Test]
- public void GetDateTimeTest ()
- {
- OdbcCommand cmd = conn.CreateCommand ();
- string sql = "SELECT * FROM test";
- cmd.CommandText = sql;
- OdbcDataReader reader = cmd.ExecuteReader (CommandBehavior.Default);
- try {
- if (reader.Read ()) {
- object ob = reader["col_datetime"];
- Assertion.AssertEquals ("Type of datetime column is wrong!",
- "System.DateTime", ob.GetType ().ToString () );
- ob = reader["col_date"];
- Assertion.AssertEquals ("Type of date column is wrong!",
- "System.DateTime", ob.GetType ().ToString () );
- // FIXME : Once TIME data type is fixed, enable this check
- //ob = reader["col_time"];
- //Assertion.AssertEquals ("Type of time column is wrong!",
- //"System.DateTime", ob.GetType ().ToString () );
-
- DateTime dt = reader.GetDateTime (4);
- Assertion.AssertEquals ("DateValue (SQL_TIMESTAMP) is wrong", new DateTime (2004, 8, 22, 0, 0, 0), dt);
- dt = reader.GetDateTime (5);
- Assertion.AssertEquals ("DateValue (SQL_DATE) is wrong", new DateTime (2004, 8, 22, 0, 0, 0), dt);
- // FIXME : Once TIME data type is fixed, enable this check
- //dt = reader.GetDateTime (7);
- //Assertion.AssertEquals ("DateValue is wrong", "2004-08-22", dt.ToString ());
- }
- } finally {
- // clean up
- if (reader != null && !reader.IsClosed )
- reader.Close ();
- reader = null;
- CleanTestSetup ();
- CloseConnection ();
- }
- }
-
-
- /// <summary>
- /// This test for the return type & value for GetValue
- /// in case of Odbc Data type TINYINT
- /// </summary>
- [Test]
- public void TinyIntTest ()
- {
- OdbcCommand cmd = conn.CreateCommand ();
- string sql = "SELECT * FROM test";
- cmd.CommandText = sql;
- OdbcDataReader reader = cmd.ExecuteReader (CommandBehavior.SequentialAccess);
- try {
- if (reader.Read ()) {
- object ob = reader.GetValue (0);
- Assertion.AssertEquals ("Type of tinyInt column is wrong!",
- "System.Byte", ob.GetType ().ToString () );
- Assertion.AssertEquals ("Value of tinyInt column is wrong!",
- 1, System.Convert.ToInt16(ob) );
- }
- } finally {
- // clean up
- if (reader != null && !reader.IsClosed )
- reader.Close ();
- reader = null;
- CleanTestSetup ();
- CloseConnection ();
- }
- }
-
- [Test]
- public void NumericTest()
- {
- using(IDbConnection dbConnection = new OdbcConnection(connectionString))
- {
- dbConnection.Open();
- IDbCommand dbCommand = dbConnection.CreateCommand();
- //note this will fail if the table already exists, ie if the test has failed.
- dbCommand.CommandText = "CREATE TABLE NumericTable (NumericField NUMERIC(10) NOT NULL)";
- dbCommand.ExecuteNonQuery();
- dbCommand.CommandText = "INSERT INTO NumericTable (NumericField) VALUES (125)";
- dbCommand.ExecuteNonQuery();
- dbCommand.CommandText = "SELECT * FROM NumericTable";
- using(IDataReader reader = dbCommand.ExecuteReader())
- {
- while(reader.Read())
- {
- for(int index = 0; index < reader.FieldCount; index++)
- {
- Object dataValue = reader.GetValue(index);
- Assert.AreEqual("System.Decimal",dataValue.GetType().ToString());
- Assert.AreEqual("125", dataValue.ToString());
- }
- }
- }
- dbCommand.CommandText = "DROP TABLE NumericTable";
- dbCommand.ExecuteNonQuery();
- }
- }
-
-
-
}
}
diff --git a/mcs/class/System.Data/Test/System.Data.SqlClient/SqlCommandTest.cs b/mcs/class/System.Data/Test/System.Data.SqlClient/SqlCommandTest.cs deleted file mode 100644 index 9d58e4c977a..00000000000 --- a/mcs/class/System.Data/Test/System.Data.SqlClient/SqlCommandTest.cs +++ /dev/null @@ -1,99 +0,0 @@ -//
-// SqlCommandTest.cs - NUnit Test Cases for testing the
-// SqlCommand class
-// Author:
-// Umadevi S (sumadevi@novell.com)
-//
-// Copyright (c) 2004 Novell Inc., and the individuals listed
-// on the ChangeLog entries.
-//
-// 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.
-//
-
-using System;
-using System.Data;
-using System.Data.Common; -using System.Data.SqlClient;
-
-using NUnit.Framework;
-
-namespace MonoTests.System.Data.SqlClient -{
-
- [TestFixture]
- public class SqlCommandTest : MSSqlTestClient {
-
- [SetUp]
- public void GetReady () {
- OpenConnection ();
- }
-
- [TearDown]
- public void Clean () {
- CloseConnection ();
- } - - /** - This is required to be run only once, call this from the GetReady. - **/ - private void setup(){ - string createquery = "CREATE PROCEDURE sp_insert @TestPar1 varchar(50),@BirthDate datetime as insert into Employees(LastName,FirstName) VALUES('SSS','uuuu') "; - SqlCommand cmd = new SqlCommand(); - cmd.Connection = conn; - cmd.CommandText = createquery; - int ret =cmd.ExecuteNonQuery(); - } - - - [Test]
- /** - The below test expects the stored procedure sp_insert in the database. - **/ - public void ExecuteNonQueryTest () { - try { - SqlCommand cmd = new SqlCommand(); - cmd.Connection = conn; - cmd.CommandText = "sp_insert"; - cmd.CommandType = CommandType.StoredProcedure; - Object TestPar = System.DBNull.Value; - cmd.Parameters.Add("@TestPar1",SqlDbType.Int); - cmd.Parameters["@TestPar1"].Value = TestPar; - cmd.Parameters.Add("@BirthDate",DateTime.Now); - Assert.AreEqual(-1,cmd.ExecuteNonQuery()); - }
- catch (Exception e) { - Assert.Fail("A#01 Got an exception"); - Console.WriteLine(e.Message); - Console.WriteLine(e.StackTrace); - - } - - finally { // try/catch is necessary to gracefully close connections
- - CloseConnection ();
- }
- }
- - - - - - }
-}
|