Parcourir la source

2002-08-05 Rodrigo Moya <[email protected]>

	* System.Data.OleDb/OleDbConnection.cs (ConnectionString,
	ConnectionTimeout, ServerVersion, GdaConnection):
	corrected style.
	(OleDbConnection): call libgda.gda_init on constructor.

	* System.Data.OleDb/libgda.cs (libgda): removed static constructor,
	which wasn't been called.

	* System.Data.OleDb/TestOleDb.cs (TestOleDb): updated to really
	make some tests.

svn path=/trunk/mcs/; revision=6450
Rodrigo Moya il y a 23 ans
Parent
commit
4e816d153a

+ 13 - 3
mcs/class/System.Data/ChangeLog

@@ -1,3 +1,16 @@
+2002-08-05  Rodrigo Moya <[email protected]>
+
+	* System.Data.OleDb/OleDbConnection.cs (ConnectionString,
+	ConnectionTimeout, ServerVersion, GdaConnection):
+	corrected style.
+	(OleDbConnection): call libgda.gda_init on constructor.
+
+	* System.Data.OleDb/libgda.cs (libgda): removed static constructor,
+	which wasn't been called.
+
+	* System.Data.OleDb/TestOleDb.cs (TestOleDb): updated to really
+	make some tests.
+
 2002-08-04  Rodrigo Moya <[email protected]>
 
 	* list: added missing System.Data.OleDb and
@@ -9,9 +22,6 @@
 	* System.Data.OleDb/OleDbDataAdapter.cs:
 	* System.Data.OleDb/OleDbPermission.cs: compilation fixes.
 
-        * System.Data.OleDb/TestOleDb.cs (TestOleDb): updated to really
-	make some tests.
-
 2002-07-30  Rodrigo Moya <[email protected]>
 
         * System.Data.OleDb/OleDbDataReader.cs (FieldCount): implemented.

+ 25 - 11
mcs/class/System.Data/System.Data.OleDb/OleDbConnection.cs

@@ -31,14 +31,15 @@ namespace System.Data.OleDb
 		
 		public OleDbConnection ()
 		{
+			libgda.gda_init ("System.Data.OleDb", "1.0", 0, null);
 			gdaConnection = IntPtr.Zero;
 			connectionTimeout = 15;
+			connectionString = null;
 		}
 
-		public OleDbConnection (string connectionString) 
-			: this ()
+		public OleDbConnection (string connectionString) : this ()
 		{
-			this.connectionString = connectionString;
+			connectionString = connectionString;
 		}
 
 		#endregion // Constructors
@@ -46,12 +47,18 @@ namespace System.Data.OleDb
 		#region Properties
 
 		public string ConnectionString {
-			get { return connectionString; }
-			set { connectionString = value; }
+			get {
+				return connectionString;
+			}
+			set {
+				connectionString = value;
+			}
 		}
 
 		public int ConnectionTimeout {
-			get { return connectionTimeout; }
+			get {
+				return connectionTimeout;
+			}
 		}
 
 		public string Database { 
@@ -83,7 +90,9 @@ namespace System.Data.OleDb
 
 		public string ServerVersion {
 			[MonoTODO]
-			get { throw new NotImplementedException (); }
+			get {
+				throw new NotImplementedException ();
+			}
 		}
 
 		public ConnectionState State
@@ -100,7 +109,9 @@ namespace System.Data.OleDb
 
 		internal IntPtr GdaConnection
 		{
-			get { return gdaConnection; }
+			get {
+				return gdaConnection;
+			}
 		}
 
 		#endregion // Properties
@@ -179,10 +190,13 @@ namespace System.Data.OleDb
 
 		public void Open ()
 		{
-			if (gdaConnection != IntPtr.Zero || libgda.gda_connection_is_open (gdaConnection))
+			if (gdaConnection != IntPtr.Zero ||
+			    libgda.gda_connection_is_open (gdaConnection))
 				throw new InvalidOperationException ();
 
-			gdaConnection = libgda.gda_client_open_connection (libgda.GdaClient, connectionString, "", "");
+			gdaConnection = libgda.gda_client_open_connection (libgda.GdaClient,
+									   connectionString,
+									   "", "");
 		}
 
 		[MonoTODO]
@@ -199,7 +213,7 @@ namespace System.Data.OleDb
 		// from doing anything while
 		// OleDbDataReader is open.
 		// Open the Reader. (called from OleDbCommand)
-		internal void OpenReader(OleDbDataReader reader)
+		internal void OpenReader (OleDbDataReader reader)
 		{
 			if(dataReaderOpen == true) {
 				// TODO: throw exception here?

+ 9 - 2
mcs/class/System.Data/System.Data.OleDb/TestOleDb.cs

@@ -10,16 +10,23 @@ namespace System.Data.OleDb.Test
 		private TestOleDb ()
 		{
 			m_cnc = new OleDbConnection ("PostgreSQL");
+			m_cnc.Open ();
 		}
 
 		void TestDataReader ()
 		{
+			string sql = "SELECT * FROM pg_tables";
+			OleDbCommand cmd = new OleDbCommand (sql, m_cnc);
 		}
 
 		static void Main (string[] args)
 		{
-			TestOleDb test = new TestOleDb ();
-			test.TestDataReader ();
+			try {
+				TestOleDb test = new TestOleDb ();
+				test.TestDataReader ();
+			} catch (Exception e) {
+				Console.Write ("An error has occured");
+			}
 		}
 	}
 }

+ 4 - 9
mcs/class/System.Data/System.Data.OleDb/libgda.cs

@@ -32,20 +32,15 @@ namespace System.Data.OleDb
 	
 	sealed internal class libgda
 	{
-		private static IntPtr m_gdaClient = IntPtr.Zero;
-		
-		static libgda ()
-		{
-			gda_init ("System.Data.OleDb", "0.1", 0, null);
-		}
+		private static IntPtr gdaClient = IntPtr.Zero;
 
 		public static IntPtr GdaClient
 		{
 			get {
-				if (m_gdaClient == IntPtr.Zero)
-					m_gdaClient = gda_client_new ();
+				if (gdaClient == IntPtr.Zero)
+					gdaClient = gda_client_new ();
 
-				return m_gdaClient;
+				return gdaClient;
 			}
 		}