2002-11-14 Daniel Morgan <danmorg@sc.rr.com>
authorDaniel Morgan <monodanmorg@yahoo.com>
Thu, 14 Nov 2002 23:27:34 +0000 (23:27 -0000)
committerDaniel Morgan <monodanmorg@yahoo.com>
Thu, 14 Nov 2002 23:27:34 +0000 (23:27 -0000)
* System.Data/DataColumnPropertyDescriptor.cs
* System.Data/DataRowView.cs
* System.Data/DataView.cs
* System.Data.Common/DbDataRecord.cs: a little bit more
implementation for data binding purposes

* Test/PostgresTest.cs
* Test/TestSqlDataAdapter.cs
* Test/TestSqlException.cs
* TestSqlParameters.cs: fixed test for PostgreSQL's new home
at Mono.Data.PostgreSqlClient

svn path=/trunk/mcs/; revision=8991

mcs/class/System.Data/ChangeLog
mcs/class/System.Data/System.Data.Common/DbDataRecord.cs
mcs/class/System.Data/System.Data/DataColumnPropertyDescriptor.cs
mcs/class/System.Data/System.Data/DataRowView.cs
mcs/class/System.Data/System.Data/DataView.cs
mcs/class/System.Data/Test/PostgresTest.cs
mcs/class/System.Data/Test/TestSqlDataAdapter.cs
mcs/class/System.Data/Test/TestSqlException.cs
mcs/class/System.Data/Test/TestSqlParameters.cs

index 489b2e3ce570bc34c72c736608b7925873829f3d..2bac0da62013cd6d48f1d1d95c19abc91cf05949 100644 (file)
@@ -1,3 +1,17 @@
+2002-11-14  Daniel Morgan <danmorg@sc.rr.com>
+
+       * System.Data/DataColumnPropertyDescriptor.cs
+       * System.Data/DataRowView.cs
+       * System.Data/DataView.cs
+       * System.Data.Common/DbDataRecord.cs: a little bit more
+       implementation for data binding purposes
+       
+       * Test/PostgresTest.cs
+       * Test/TestSqlDataAdapter.cs
+       * Test/TestSqlException.cs
+       * TestSqlParameters.cs: fixed test for PostgreSQL's new home
+       at Mono.Data.PostgreSqlClient
+
 2002-11-14  Tim Coleman <tim@timcoleman.com>
        * System.Data.SqlClient/SqlCommand.cs:
                Slight reformatting of Bit values and sql statements
index c2ea01de264be5e49aee067349f0f5e7671ce4a9..2f4d73ea495eb2fe3afb2ef0741ac90f8888b79e 100644 (file)
@@ -45,6 +45,7 @@ namespace System.Data.Common {
                        get { return this [GetOrdinal (name)]; }
                }
 
+               [System.Runtime.CompilerServices.IndexerName("Item")]
                public object this [int index] {
                        get { return GetValue (index); }
                }       
@@ -159,79 +160,101 @@ namespace System.Data.Common {
                [MonoTODO]
                public int GetValues (object[] values)
                {
-                       throw new NotImplementedException ();
+                       object[] newArray = new object[this.values.Length];
+                       values.CopyTo (newArray, 0);
+                       return values.Length;
                }
 
                [MonoTODO]
                AttributeCollection ICustomTypeDescriptor.GetAttributes ()
                {
-                       throw new NotImplementedException ();
+                       return new AttributeCollection(null);
                }
 
                [MonoTODO]
                string ICustomTypeDescriptor.GetClassName ()
                {
-                       throw new NotImplementedException ();
+                       return "";
                }
 
                [MonoTODO]
                string ICustomTypeDescriptor.GetComponentName ()
                {
-                       throw new NotImplementedException ();
+                       return null;
                }
 
                [MonoTODO]
                TypeConverter ICustomTypeDescriptor.GetConverter ()
                {
-                       throw new NotImplementedException ();
+                       return null;
                }       
 
                [MonoTODO]
                EventDescriptor ICustomTypeDescriptor.GetDefaultEvent ()
                {
-                       throw new NotImplementedException ();
+                       return null;
                }       
 
                [MonoTODO]
                PropertyDescriptor ICustomTypeDescriptor.GetDefaultProperty ()
                {
-                       throw new NotImplementedException ();
+                       return null;
                }       
 
                [MonoTODO]
                object ICustomTypeDescriptor.GetEditor (Type editorBaseType)
                {
-                       throw new NotImplementedException ();
+                       return null;
                }       
 
                [MonoTODO]
                EventDescriptorCollection ICustomTypeDescriptor.GetEvents ()
                {
-                       throw new NotImplementedException ();
+                       return new EventDescriptorCollection(null);
                }       
 
                [MonoTODO]
                EventDescriptorCollection ICustomTypeDescriptor.GetEvents (Attribute[] attributes)
                {
-                       throw new NotImplementedException ();
+                       return new EventDescriptorCollection(null);
                }       
 
                [MonoTODO]
                PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties ()
                {
-                       throw new NotImplementedException ();
+                       DataColumnPropertyDescriptor[] descriptors = 
+                               new DataColumnPropertyDescriptor[FieldCount];
+
+                       DataColumnPropertyDescriptor descriptor;
+                       DataColumn dataColumn;
+                       for(int col = 0; col < FieldCount; col++) {
+                               descriptor = new DataColumnPropertyDescriptor(
+                                       GetName(col), col, null);
+                               descriptor.SetComponentType(typeof(DbDataRecord));
+                               descriptor.SetPropertyType(GetFieldType(col));
+                               
+                               descriptors[col] = descriptor;
+                       }
+
+                       return new PropertyDescriptorCollection (descriptors);
                }       
 
                [MonoTODO]
                PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties (Attribute[] attributes)
                {
-                       throw new NotImplementedException ();
+                       PropertyDescriptorCollection descriptors;
+                       descriptors = ((ICustomTypeDescriptor) this).GetProperties ();
+                       // TODO: filter out descriptors which do not contain
+                       //       any of those attributes
+                       //       except, those descriptors 
+                       //       that contain DefaultMemeberAttribute
+                       return descriptors;
                }       
 
                [MonoTODO]
                object ICustomTypeDescriptor.GetPropertyOwner (PropertyDescriptor pd)
                {
-                       throw new NotImplementedException ();
+                       return this;
                }       
 
                public bool IsDBNull (int i)
index 5cc921b71e29503bbffdf724e9233564e3021278..3a1e645f4727829469a840fc4087f8e74e2b3ea8 100755 (executable)
@@ -8,6 +8,7 @@
 //
 
 using System;
+using System.Data.Common;
 using System.ComponentModel;
 using System.Reflection;
 
@@ -19,8 +20,9 @@ namespace System.Data
                private Type componentType = null;
                private Type propertyType = null;
                private PropertyInfo prop = null;
+               private int columnIndex = 0;
 
-               public DataColumnPropertyDescriptor (string name, Attribute [] attrs)
+               public DataColumnPropertyDescriptor (string name, int columnIndex, Attribute [] attrs)
                        : base (name, attrs) 
                {
                }
@@ -65,6 +67,18 @@ namespace System.Data
 
                public override object GetValue (object component) 
                {
+                       // FIXME: what is the correct way to Get a Value?
+                       if(componentType == typeof(DataRowView) && component is DataRowView) {
+                               DataRowView drv = (DataRowView) component;
+                               return drv[base.Name];
+                       }
+                       else if(component == typeof(DbDataRecord) && component is DbDataRecord) {
+                               DbDataRecord dr = (DbDataRecord) component;
+                               return dr[columnIndex];
+                       }
+                       throw new InvalidOperationException();
+
+                       /*
                        if (prop == null)
                                prop = GetPropertyInfo ();              
                                                        \r
@@ -72,10 +86,14 @@ namespace System.Data
                        object[] parms = new object[1];\r
                        parms[0] = base.Name;\r
                        return prop.GetValue (component, parms);
+                       */
                }
 
                public override void SetValue(object component, object value) 
                {
+                       DataRowView drv = (DataRowView) component;
+                       drv[base.Name] = value;
+                       /*
                        if (prop == null)
                                prop = GetPropertyInfo ();              
 
@@ -88,24 +106,25 @@ namespace System.Data
                        object[] parms = new Object[1];\r
                        parms[0] = base.Name;\r
                        prop.SetValue (component, value, parms);
+                       */
                }
 
                [MonoTODO]
                public override void ResetValue(object component) 
                {
-                       throw new NotImplementedException ();
+                       // FIXME:
                }
 
                [MonoTODO]
                public override bool CanResetValue(object component) 
                {
-                       throw new NotImplementedException ();
+                       return false; // FIXEME
                }
 
                [MonoTODO]
                public override bool ShouldSerializeValue(object component) 
                {
-                       throw new NotImplementedException ();
+                       return false;
                }
 
                public override Type ComponentType {
index 21c5d5038774ce60b15e07eafcff28bb81b3c64c..3af7e3c19a1bf1bc6e4d9a391678dcb9b250c3ac 100644 (file)
@@ -20,14 +20,17 @@ namespace System.Data
        /// <summary>
        /// Represents a customized view of a DataRow exposed as a fully featured Windows Forms control.
        /// </summary>
-       //[DefaultMember("Item")]
-       [DefaultProperty("Item")]
        public class DataRowView : ICustomTypeDescriptor, IEditableObject, IDataErrorInfo
        {
                #region Fields
 
-               private DataView dataView;
-               private DataRow dataRow;
+               DataView dataView;
+               DataRow dataRow;
+               DataRowVersion rowVersion = DataRowVersion.Default;
+
+               // FIXME: what are the defaults?
+               bool isEdit = false;
+               bool isNew = false;
 
                #endregion // Fields
 
@@ -45,13 +48,13 @@ namespace System.Data
                [MonoTODO]
                public void BeginEdit ()
                {
-                       throw new NotImplementedException ();
+                       // FIXME:
                }
 
                [MonoTODO]
                public void CancelEdit ()
                {
-                       throw new NotImplementedException ();
+                       // FIXME:
                }
 
                [MonoTODO]
@@ -75,7 +78,7 @@ namespace System.Data
                [MonoTODO]
                public void EndEdit ()
                {
-                       throw new NotImplementedException ();
+                       // FIXME:
                }
 
                #endregion // Methods
@@ -93,17 +96,18 @@ namespace System.Data
                public bool IsEdit {
                        [MonoTODO]
                        get {
-                               throw new NotImplementedException ();
+                               return isEdit;
                        }
                }
 
                public bool IsNew {
                        [MonoTODO]
                        get {
-                               throw new NotImplementedException ();
+                               return isNew;
                        }
                }
                
+               [System.Runtime.CompilerServices.IndexerName("Item")]
                public object this[string column] {
                        [MonoTODO]
                        get {
@@ -119,10 +123,12 @@ namespace System.Data
 
                public string Error {
                        get {
-                               throw new NotImplementedException ();
+                               return ""; // FIXME:
                        }
                }
-
+                
+               // the compiler creates a DefaultMemeberAttribute from
+               // this IndexerNameAttribute
                public object this[int column] {
                        [MonoTODO]
                        get {
@@ -147,7 +153,7 @@ namespace System.Data
                public DataRowVersion RowVersion {
                        [MonoTODO]
                        get {
-                               throw new NotImplementedException ();
+                               return rowVersion;
                        }
                }
 
@@ -161,10 +167,6 @@ namespace System.Data
                        System.ComponentModel.AttributeCollection attributes;\r
                        attributes = AttributeCollection.Empty;\r
                        return attributes;\r
-                       //object[] attributes = this.GetType ().GetCustomAttributes (true);
-                       //AttributeCollection attribCollection;
-                       //attribCollection = new AttributeCollection (attributes);
-                       //return attribCollection;
                }
 
                [MonoTODO]
@@ -176,7 +178,7 @@ namespace System.Data
                [MonoTODO]
                string ICustomTypeDescriptor.GetComponentName ()
                {
-                       return "";
+                       return null;
                }
 
                [MonoTODO]
@@ -188,7 +190,7 @@ namespace System.Data
                [MonoTODO]
                EventDescriptor ICustomTypeDescriptor.GetDefaultEvent ()
                {
-                       throw new NotImplementedException ();
+                       return null;
                }
                
                [MonoTODO]
@@ -200,19 +202,19 @@ namespace System.Data
                [MonoTODO]
                object ICustomTypeDescriptor.GetEditor (Type editorBaseType)
                {
-                       throw new NotImplementedException ();
+                       return null;
                }
                
                [MonoTODO]
                EventDescriptorCollection ICustomTypeDescriptor.GetEvents ()
                {
-                       throw new NotImplementedException ();
+                       return new EventDescriptorCollection(null);
                }
 
                [MonoTODO]
                EventDescriptorCollection ICustomTypeDescriptor.GetEvents (Attribute [] attributes)
                {
-                       throw new NotImplementedException ();
+                       return new EventDescriptorCollection(null);
                }
 
                [MonoTODO]
@@ -227,14 +229,17 @@ namespace System.Data
                {
                        PropertyDescriptorCollection descriptors;
                        descriptors = ((ICustomTypeDescriptor) this).GetProperties ();
-                       // TODO: filter out any Attributes not in the attributes array
+                       // TODO: filter out descriptors which do not contain
+                       //       any of those attributes
+                       //       except, those descriptors 
+                       //       that contain DefaultMemeberAttribute
                        return descriptors;
                }
                
                [MonoTODO]
                object ICustomTypeDescriptor.GetPropertyOwner (PropertyDescriptor pd)
                {
-                       throw new NotImplementedException ();
+                       return this;
                }
 
                #endregion // ICustomTypeDescriptor implementations
@@ -244,14 +249,14 @@ namespace System.Data
                string IDataErrorInfo.Error {
                        [MonoTODO]
                        get {
-                               throw new NotImplementedException();
+                               return ""; // FIXME
                        }
                }
 
                string IDataErrorInfo.this[string columnName] {
                        [MonoTODO]
                        get {
-                               throw new NotImplementedException();
+                               return ""; // FIXME
                        }
                }
 
index 0c79cdc003a3fa2109d5b3804332af1aecdf5068..1649081c4901c7b8360d3aac7a04088288901bb3 100644 (file)
@@ -12,6 +12,7 @@
 using System;
 using System.Collections;
 using System.ComponentModel;
+using System.Reflection;
 
 namespace System.Data {
        /// <summary>
@@ -29,6 +30,17 @@ namespace System.Data {
                string rowFilter = "";
                string sort = "";
                DataViewRowState rowState;
+               
+               // FIXME: what are the default values?
+               bool allowNew = true; 
+               bool allowEdit = true;
+               bool allowDelete = true;
+               bool applyDefaultSort = false;
+               bool isSorted = false;
+
+               bool isOpen = false;
+
+               DataViewManager dataViewManager = null;
 
                [MonoTODO]      
                public DataView () {
@@ -41,6 +53,7 @@ namespace System.Data {
 
                        dataTable = table;
                        rowState = DataViewRowState.None;
+                       Open ();
                }
 
                [MonoTODO]
@@ -50,6 +63,8 @@ namespace System.Data {
                        rowFilter = RowFilter;
                        sort = Sort;
                        rowState = RowState;
+
+                       Open();
                }
 
                [DataCategory ("Data")]
@@ -58,12 +73,12 @@ namespace System.Data {
                public bool AllowDelete {
                        [MonoTODO]
                        get {
-                               throw new NotImplementedException ();
+                               return allowDelete;
                        }
                        
                        [MonoTODO]
                        set {
-                               throw new NotImplementedException ();
+                               allowDelete = value;
                        }
                }
 
@@ -73,12 +88,12 @@ namespace System.Data {
                public bool AllowEdit {
                        [MonoTODO]
                        get {
-                               throw new NotImplementedException ();
+                               return allowEdit;
                        }
                        
                        [MonoTODO]
                        set {
-                               throw new NotImplementedException ();
+                               allowEdit = value;
                        }
                }
 
@@ -88,12 +103,12 @@ namespace System.Data {
                public bool AllowNew {
                        [MonoTODO]
                        get {
-                               throw new NotImplementedException ();
+                               return allowNew;
                        }
                        
                        [MonoTODO]
                        set {
-                               throw new NotImplementedException ();
+                               allowNew = value;
                        }
                }
 
@@ -103,13 +118,13 @@ namespace System.Data {
                [RefreshProperties (RefreshProperties.All)]
                public bool ApplyDefaultSort {
                        [MonoTODO]
-                       get {
-                               throw new NotImplementedException ();
+                       get {                           
+                               return applyDefaultSort;
                        }
                        
                        [MonoTODO]
                        set {
-                               throw new NotImplementedException ();
+                               applyDefaultSort = value;
                        }
                }
 
@@ -131,11 +146,14 @@ namespace System.Data {
                public DataViewManager DataViewManager {
                        [MonoTODO]
                        get {
-                               throw new NotImplementedException ();
+                               return dataViewManager;
                        }
                }
 
                // Item indexer
+               // the compiler creates a DefaultMemeberAttribute from
+               // this IndexerNameAttribute
+               [System.Runtime.CompilerServices.IndexerName("Item")]
                public DataRowView this[int recordIndex] {
                        [MonoTODO]
                        get {
@@ -149,12 +167,12 @@ namespace System.Data {
                public virtual string RowFilter {
                        [MonoTODO]
                        get {
-                               throw new NotImplementedException ();
+                               return rowFilter;
                        }
                        
                        [MonoTODO]
                        set {
-                               throw new NotImplementedException ();
+                               rowFilter = value;
                        }
                }
 
@@ -164,12 +182,12 @@ namespace System.Data {
                public DataViewRowState RowStateFilter {
                        [MonoTODO]
                        get {
-                               throw new NotImplementedException ();
+                               return rowState;
                        }
                        
                        [MonoTODO]
                        set {
-                               throw new NotImplementedException ();
+                               rowState = value;
                        }
                }
 
@@ -179,12 +197,12 @@ namespace System.Data {
                public string Sort {
                        [MonoTODO]
                        get {
-                               throw new NotImplementedException ();
+                               return sort;
                        }
                        
                        [MonoTODO]
                        set {
-                               throw new NotImplementedException ();
+                               sort = value;
                        }
                }
 
@@ -211,7 +229,7 @@ namespace System.Data {
 
                [MonoTODO]
                public void BeginInit() {
-                       throw new NotImplementedException ();
+                       // FIXME:
                }
 
                [MonoTODO]
@@ -230,7 +248,7 @@ namespace System.Data {
 
                [MonoTODO]
                public void EndInit() {
-                       throw new NotImplementedException ();
+                       // FIXME:
                }
 
                [MonoTODO]
@@ -271,13 +289,14 @@ namespace System.Data {
                protected bool IsOpen {
                        [MonoTODO]
                        get {
-                               throw new NotImplementedException ();
+                               return isOpen;
                        }
                }
 
                [MonoTODO]
                protected void Close() {
-                       throw new NotImplementedException ();
+                       // FIXME:
+                       isOpen = false;
                }
 
                [MonoTODO]
@@ -303,7 +322,8 @@ namespace System.Data {
 
                [MonoTODO]
                protected void Open() {
-                       
+                       // FIXME:
+                       isOpen = true;
                }
                
                [MonoTODO]
@@ -322,7 +342,7 @@ namespace System.Data {
                                dataColumn = dataTable.Columns[col];
                                
                                descriptor = new DataColumnPropertyDescriptor(
-                                       dataColumn.ColumnName, null);
+                                       dataColumn.ColumnName, col, null);
                                descriptor.SetComponentType(typeof(System.Data.DataRowView));
                                descriptor.SetPropertyType(dataColumn.DataType);
                                
@@ -346,7 +366,7 @@ namespace System.Data {
                bool ICollection.IsSynchronized { 
                        [MonoTODO]
                        get {
-                               throw new NotImplementedException ();
+                               return false;
                        } 
                }
 
@@ -354,7 +374,7 @@ namespace System.Data {
                        [MonoTODO]
                        get {
                                // FIXME:
-                               throw new NotImplementedException ();
+                               return this;
                        }
                }
 
@@ -365,141 +385,158 @@ namespace System.Data {
                bool IList.IsFixedSize {
                        [MonoTODO]
                        get {
-                               throw new NotImplementedException ();
+                               return false;
                        }
                }
                
                bool IList.IsReadOnly {
                        [MonoTODO]
                        get {
-                               throw new NotImplementedException ();
+                               return false;
                        }
                }
 
                object IList.this[int recordIndex] {
+                       [MonoTODO]
                        get {
                                return this[recordIndex];
                        }
 
                        [MonoTODO]
                        set{
-                               // FIXME: throw an exception
-                               // because it can not be set
-                               throw new InvalidOperationException("Can not set Item property of a DataView");
+                               throw new InvalidOperationException();
                        }\r
                }
 
+               [MonoTODO]
                int IList.Add (object value) {
                        throw new NotImplementedException ();
                }
 
+               [MonoTODO]
                void IList.Clear () {
                        throw new NotImplementedException ();
                }
 
+               [MonoTODO]
                bool IList.Contains (object value) {
                        throw new NotImplementedException ();
                }
 
+               [MonoTODO]
                int IList.IndexOf (object value) {
                        throw new NotImplementedException ();
                }
-                               
+                       
+               [MonoTODO]
                void IList.Insert(int index,object value) {
                        throw new NotImplementedException ();
                }
 
+               [MonoTODO]
                void IList.Remove(object value) {
                        throw new NotImplementedException ();
                }
 
+               [MonoTODO]
                void IList.RemoveAt(int index) {
                        throw new NotImplementedException ();
                }
 
                #region IBindingList implementation
 
+               [MonoTODO]
                void IBindingList.AddIndex (PropertyDescriptor property) {
                        throw new NotImplementedException ();
                }
 
+               [MonoTODO]
                object IBindingList.AddNew () {
                        throw new NotImplementedException ();
                }
 
+               [MonoTODO]
                void IBindingList.ApplySort (PropertyDescriptor property, ListSortDirection direction) {
                        throw new NotImplementedException ();
                }
 
+               [MonoTODO]
                int IBindingList.Find (PropertyDescriptor property, object key) {
                        throw new NotImplementedException ();
                }
 
+               [MonoTODO]
                void IBindingList.RemoveIndex (PropertyDescriptor property) {
                        throw new NotImplementedException ();
                }
 
+               [MonoTODO]
                void IBindingList.RemoveSort () {
                        throw new NotImplementedException ();
                }
                
                bool IBindingList.AllowEdit {
+                       [MonoTODO]
                        get {
-                               throw new NotImplementedException ();
+                               return AllowEdit;
                        }
                }
 
                bool IBindingList.AllowNew {
+                       [MonoTODO]
                        get {
-                               throw new NotImplementedException ();
+                               return AllowNew;
                        }
                }
 
                bool IBindingList.AllowRemove {
+                       [MonoTODO]
                        get {
-                               throw new NotImplementedException ();
+                               return AllowDelete;
                        }
                }
 
                bool IBindingList.IsSorted {
                        [MonoTODO]
                        get {
-                               throw new NotImplementedException ();
+                               return isSorted;
                        }
                }
 
                ListSortDirection IBindingList.SortDirection {
                        [MonoTODO]
                        get {
-                               throw new NotImplementedException ();
+                               // FIXME: 
+                               return ListSortDirection.Ascending;
                        }
                }
 
                PropertyDescriptor IBindingList.SortProperty {
                        [MonoTODO]
                        get {
-                               throw new NotImplementedException ();
+                               // FIXME:
+                               return null;
                        }
                }
 
                bool IBindingList.SupportsChangeNotification {
                        [MonoTODO]
                        get {
-                               throw new NotImplementedException ();
+                               return false;
                        }
                }
 
                bool IBindingList.SupportsSearching {
                        [MonoTODO]
                        get {
-                               throw new NotImplementedException ();
+                               return false;
                        }
                }
 
                bool IBindingList.SupportsSorting {
                        [MonoTODO]
                        get {
-                               throw new NotImplementedException ();
+                               return false;
                        }
                }
 
index 95b50d55a7c2e87df71dc5c4635f69583bf648c2..e60e523d3633b0e1f3c55dafdfd86766031e62e2 100644 (file)
@@ -485,26 +485,42 @@ namespace Test.Mono.Data.PostgreSqlClient {
 
                [STAThread]\r
                static void Main(string[] args) {\r
+                       Console.WriteLine("Tests Start.");\r
+                       Console.WriteLine("Creating PgSqlConnectioin...");\r
                        PgSqlConnection cnc = new PgSqlConnection ();\r
 \r
-                       /*\r
-                       string connectionString = 
-                               "host=hostname;" +
-                               "dbname=database;" +
-                               "user=userid;" +
-                               "password=password";
-                       */\r
+                       // possible PostgreSQL Provider ConnectionStrings\r
+                       //string connectionString = 
+                       //      "Server=hostname;" +
+                       //      "Database=database;" +
+                       //      "User ID=userid;" +
+                       //      "Password=password";\r
+                       // or\r
+                       //string connectionString = 
+                       //      "host=hostname;" +
+                       //      "dbname=database;" +
+                       //      "user=userid;" +
+                       //      "password=password";
 \r
                        string connectionString = 
                                "host=localhost;" +
                                "dbname=test;" +
-                               "user=postgres;";
-\r
+                               "user=postgres";
+                        \r
+                       Console.WriteLine("Setting ConnectionString: " +\r
+                               connectionString);\r
                        cnc.ConnectionString =  connectionString;\r
 \r
+                       Console.WriteLine("Opening database connection...");\r
                        cnc.Open();\r
+\r
+                       Console.WriteLine("Do Tests....");\r
                        DoPostgresTest(cnc);
+
+                       Console.WriteLine("Close database connection...");
                        cnc.Close();
+
+                       Console.WriteLine("Tests Done.");
                }
        }
 }
index 684bfa834858d0e3ad245cec0cb4521e53c18954..37c5ff78bf5d2bb3a7e8b094d1188bed23bd5633 100644 (file)
@@ -1,5 +1,5 @@
 //
-// TestSqlDataAdapter - tests SqlDataAdapter, DbDataAdapter, DataSet, DataTable,
+// TestPgSqlDataAdapter - tests PgSqlDataAdapter, DbDataAdapter, DataSet, DataTable,
 //                      DataRow, and DataRowCollection by retrieving data
 //
 // Authors:
 using System;
 using System.Collections;
 using System.Data;
-using System.Data.SqlClient;
+using Mono.Data.PostgreSqlClient;
 
-namespace TestSystemDataSqlClient 
+namespace TestSystemDataPgSqlClient 
 {
-       public class TestSqlDataAdapter 
+       public class TestPgSqlDataAdapter 
        {
                public static void Test() 
                {
                        string connectionString;
                        string sqlQuery;
-                       SqlDataAdapter adapter;
+                       PgSqlDataAdapter adapter;
                        DataSet dataSet = null;
 
                        connectionString =
@@ -33,8 +33,8 @@ namespace TestSystemDataSqlClient
                                                
                        sqlQuery = "select * from pg_tables";
 
-                       System.Console.WriteLine ("new SqlDataAdapter...");
-                       adapter = new SqlDataAdapter (sqlQuery, 
+                       System.Console.WriteLine ("new PgSqlDataAdapter...");
+                       adapter = new PgSqlDataAdapter (sqlQuery, 
                                        connectionString);
 
                        System.Console.WriteLine ("new DataSet...");
index 294a1ddfba3a47e47f62bfc5be6cf254aec10ca4..ae5ed37c5d3269a66ff5d24f36843bc6929078de 100644 (file)
@@ -1,7 +1,7 @@
 //
-// TestSqlInsert.cs
+// TestPgSqlInsert.cs
 //
-// To Test SqlConnection and SqlCommand by connecting
+// To Test PgSqlConnection and PgSqlCommand by connecting
 // to a PostgreSQL database 
 // and then executing an INSERT SQL statement
 //
@@ -11,8 +11,8 @@
 //        insertStatement
 //
 // To test:
-//   mcs TestSqlInsert.cs -r System.Data
-//   mint TestSqlInsert.exe
+//   mcs TestPgSqlInsert.cs -r System.Data
+//   mint TestPgSqlInsert.exe
 //
 // Author:
 //   Rodrigo Moya (rodrigo@ximian.com)
 
 using System;
 using System.Data;
-using System.Data.SqlClient;
+using Mono.Data.PostgreSqlClient;
 
-namespace TestSystemDataSqlClient
+namespace TestSystemDataPgSqlClient
 {
-       class TestSqlInsert
+       class TestPgSqlInsert
        {
                [STAThread]
                static void Main(string[] args) {
-                       SqlConnection conn;
-                       SqlCommand cmd;
-                       SqlTransaction trans;
+                       PgSqlConnection conn = null;
+                       PgSqlCommand cmd = null;
+                       PgSqlTransaction trans = null;
 
-                       int rowsAffected;
+                       int rowsAffected = -1;
 
-                       String connectionString;
-                       String insertStatement;
-                       String deleteStatement;
+                       String connectionString = "";
+                       String insertStatement = "";
+                       String deleteStatement = "";
        
                        connectionString = 
                                "host=localhost;" +
@@ -58,7 +58,7 @@ namespace TestSystemDataSqlClient
                        try {
                                // Connect to a PostgreSQL database
                                Console.WriteLine ("Connect to database...");
-                               conn = new SqlConnection(connectionString);
+                               conn = new PgSqlConnection(connectionString);
                                conn.Open();
                        
                                // begin transaction
@@ -68,7 +68,7 @@ namespace TestSystemDataSqlClient
                                // create SQL DELETE command
                                Console.WriteLine ("Create Command initializing " +
                                        "with an DELETE statement...");
-                               cmd = new SqlCommand (deleteStatement, conn);
+                               cmd = new PgSqlCommand (deleteStatement, conn);
 
                                // execute the DELETE SQL command
                                Console.WriteLine ("Execute DELETE SQL Command...");
@@ -99,9 +99,9 @@ namespace TestSystemDataSqlClient
                                Console.WriteLine ("Verify data in database to " +
                                        "see if row is there.");
                        }
-                       catch(SqlException e) {
+                       catch(PgSqlException e) {
                                // Display the SQL Errors and Rollback the database
-                               Console.WriteLine("SqlException caught: " +
+                               Console.WriteLine("PgSqlException caught: " +
                                        e.ToString());
                                if(trans != null) {
                                        trans.Rollback();
index 5080799959206d846c6f4c249525cc6e38e0ef4d..92b680e4b65f08523b8ae3b53a51d617de00ecca 100644 (file)
@@ -1,6 +1,6 @@
 //\r
 // TestSqlParameters.cs - test parameters for the PostgreSQL .NET Data Provider in Mono\r
-//                        using *Parameter and *ParameterCollection\r
+//                        using PgSqlParameter and PgSqlParameterCollection\r
 //\r
 // Note: it currently only tests input parameters.  Output is next on the list.\r
 //       Then output/input and return parameters.\r
@@ -14,9 +14,9 @@
 using System;\r
 using System.Collections;\r
 using System.Data;\r
-using System.Data.SqlClient;\r
+using Mono.Data.PostgreSqlClient;\r
 \r
-namespace TestSystemDataSqlClient {\r
+namespace TestSystemDataPgSqlClient {\r
 \r
        public class TestParameters {\r
                public static void Main() {\r
@@ -28,9 +28,9 @@ namespace TestSystemDataSqlClient {
                                "dbname=test;" +
                                "user=postgres";
                                                \r
-                       SqlConnection con;\r
+                       PgSqlConnection con;\r
                        Console.WriteLine("** Creating connection...");\r
-                       con = new SqlConnection(connectionString);\r
+                       con = new PgSqlConnection(connectionString);\r
                        Console.WriteLine("** opening connection...");\r
                        con.Open();\r
                \r
@@ -40,11 +40,11 @@ namespace TestSystemDataSqlClient {
                        sql = "SELECT * FROM PG_TABLES WHERE TABLENAME = :inTableName";\r
                                                \r
                        Console.WriteLine("** Creating command...");\r
-                       SqlCommand cmd = new SqlCommand(sql, con);\r
+                       PgSqlCommand cmd = new PgSqlCommand(sql, con);\r
                        \r
                        // add parameter for inTableName\r
                        Console.WriteLine("** Create parameter...");\r
-                       SqlParameter parm = new SqlParameter("inTableName", SqlDbType.Text);\r
+                       PgSqlParameter parm = new PgSqlParameter("inTableName", DbType.String);\r
                        \r
                        Console.WriteLine("** set dbtype of parameter to string");\r
                        parm.DbType = DbType.String;\r
@@ -58,7 +58,7 @@ namespace TestSystemDataSqlClient {
                        Console.WriteLine("** add parameter to parameters collection in the command...");\r
                        cmd.Parameters.Add(parm);\r
                        \r
-                       SqlDataReader rdr;\r
+                       PgSqlDataReader rdr;\r
                        Console.WriteLine("** ExecuteReader()...");\r
                        \r
                        rdr = cmd.ExecuteReader();\r