-<p>
-<pre>
-\r
-danmorg@DANPC ~/mono/mcs/class/System.Data/Test\r
-$ mcs PostgresTest.cs -r System.Data.dll\r
-\r
-danmorg@DANPC ~/mono/mcs/class/System.Data/Test\r
-$ mono PostgresTest.exe\r
- Postgres provider specific tests...\r
-\r
- Drop table:\r
-Error (don't worry about this one)SqlError:PGRES_FATAL_ERROR ERROR: table "mono\r
-_postgres_test" does not exist\r
- <Stack Trace>\r
-\r
- Create table with all supported types:\r
-OK\r
- Insert values for all known types:\r
-OK\r
- Update values:\r
-OK\r
- Insert values for all known types:\r
-OK\r
-Aggregate: count(*)\r
-Agg Result: 2\r
-Aggregate: min(text_value)\r
-Agg Result: This is a text\r
-Aggregate: max(int4_value)\r
-Agg Result: 1048000\r
-Aggregate: sum(int4_value)\r
-Agg Result: 1048003\r
- Select values from the database:\r
-Result is from a SELECT SQL Query. Records Affected: -1\r
-Result Set 1...\r
- Total Columns: 28\r
-ColumnName = boolean_value\r
-ColumnOrdinal = 1\r
-ColumnSize = 1\r
-NumericPrecision = 0\r
-NumericScale = 0\r
-IsUnique = False\r
-IsKey =\r
-BaseCatalogName =\r
-BaseColumnName = boolean_value\r
-BaseSchemaName =\r
-BaseTableName =\r
-DataType = System.Boolean\r
-AllowDBNull = False\r
-ProviderType = 16\r
-IsAliased = False\r
-IsExpression = False\r
-IsIdentity = False\r
-IsAutoIncrement = False\r
-IsRowVersion = False\r
-IsHidden = False\r
-IsLong = False\r
-IsReadOnly = False\r
-\r
- ...\r
-\r
- ColumnName = null_timestamp_value\r
- ColumnOrdinal = 28\r
- ColumnSize = 8\r
- NumericPrecision = 0\r
- NumericScale = 0\r
- IsUnique = False\r
- IsKey =\r
- BaseCatalogName =\r
- BaseColumnName = null_timestamp_value\r
- BaseSchemaName =\r
- BaseTableName =\r
- DataType = System.DateTime\r
- AllowDBNull = False\r
- ProviderType = 1184\r
- IsAliased = False\r
- IsExpression = False\r
- IsIdentity = False\r
- IsAutoIncrement = False\r
- IsRowVersion = False\r
- IsHidden = False\r
- IsLong = False\r
- IsReadOnly = False\r
-\r
- Gonna do a Read() now...\r
- Row 0:\r
- Col 0: boolean_value: False\r
- Col 1: int2_value: 5\r
- Col 2: int4_value: 3\r
- Col 3: bigint_value: 9\r
- Col 4: float_value: 3.141590\r
- Col 5: double_value: 3.14159\r
- Col 6: numeric_value: 123456789012.345\r
- Col 7: char_value: Mono.Data!\r
- Col 8: varchar_value: It was not me!\r
- Col 9: text_value: We got data!\r
- Col 10: point_value: (1,0)\r
- Col 11: time_value: 01/01/1 21:13:14\r
- Col 12: date_value: 02/29/2000 00:00:00\r
- Col 13: timestamp_value: 02/29/2004 14:00:11\r
- Col 14: null_boolean_value is NULL\r
- Col 15: null_int2_value is NULL\r
- Col 16: null_int4_value is NULL\r
- Col 17: null_bigint_value is NULL\r
- Col 18: null_float_value is NULL\r
- Col 19: null_double_value is NULL\r
- Col 20: null_numeric_value is NULL\r
- Col 21: null_char_value is NULL\r
- Col 22: null_varchar_value is NULL\r
- Col 23: null_text_value is NULL\r
- Col 24: null_point_value is NULL\r
- Col 25: null_time_value is NULL\r
- Col 26: null_date_value is NULL\r
- Col 27: null_timestamp_value is NULL\r
- Row 1:\r
- Col 0: boolean_value: True\r
- Col 1: int2_value: -22\r
- Col 2: int4_value: 1048000\r
- Col 3: bigint_value: 123456789012345\r
- Col 4: float_value: 3.141590\r
- Col 5: double_value: 3.14159\r
- Col 6: numeric_value: 123456789012.345\r
- Col 7: char_value: This is a char\r
- Col 8: varchar_value: This is a varchar\r
- Col 9: text_value: This is a text\r
- Col 10: point_value: (1,0)\r
- Col 11: time_value: 01/01/1 21:13:14\r
- Col 12: date_value: 02/29/2000 00:00:00\r
- Col 13: timestamp_value: 02/29/2004 14:00:11\r
- Col 14: null_boolean_value is NULL\r
- Col 15: null_int2_value is NULL\r
- Col 16: null_int4_value is NULL\r
- Col 17: null_bigint_value is NULL\r
- Col 18: null_float_value is NULL\r
- Col 19: null_double_value is NULL\r
- Col 20: null_numeric_value is NULL\r
- Col 21: null_char_value is NULL\r
- Col 22: null_varchar_value is NULL\r
- Col 23: null_text_value is NULL\r
- Col 24: null_point_value is NULL\r
- Col 25: null_time_value is NULL\r
- Col 26: null_date_value is NULL\r
- Col 27: null_timestamp_value is NULL\r
- Total Rows Retrieved: 2\r
- Total Result sets: 1\r
- Call ExecuteReader with a SQL Command. (Not INSERT,UPDATE,DELETE\r
- ).\r
- Result is from a SQL Command not (INSERT,UPDATE,DELETE). Records Affected: -1\r
- Total Result sets: 0\r
- Call ExecuteReader with a SQL Command. (Is INSERT,UPDATE,DELETE)\r
- .\r
- Result is from a SQL Command (INSERT,UPDATE,DELETE). Records Affected: 1\r
- Total Result sets: 0\r
- Calling stored procedure version()\r
- Result: PostgreSQL 7.2.1 on i686-pc-cygwin, compiled by GCC 2.95.3-5\r
- Database Server Version: PostgreSQL 7.2.1 on i686-pc-cygwin, compiled by GCC 2.9\r
- 5.3-5\r
- Clean up...\r
- Drop table...\r
- OK\r
- RESULT: 0\r
-\r
-</pre>\r
-\r
+** Testing Npgsql
+
+<ul>
+ <li>Have a working mono and mcs</li>
+
+ <li>Get <a href="http://gborg.postgresql.org/project/npgsql/projdisplay.php">Npgsql</a>
+ and make sure the binary assembly Npgsql.dll is installed in the same place that the
+ mono class libraries are located.
+
+ <li>Read the Testing notes for Mono.Data.PostgreSqlClient too
+
+ <li>C# Example for Npgsql:
+<pre>
+ using System;
+ using System.Data;
+ using Npgsql;
+
+ public class Test
+ {
+ public static void Main(string[] args)
+ {
+ string connectionString =
+ "Server=localhost;" +
+ "Database=test;" +
+ "User ID=postgres;" +
+ "Password=fun2db;";
+ IDbConnection dbcon;
+ dbcon.Open();
+ dbcon = new NpgsqlConnection(connectionString);
+ IDbCommand dbcmd = dbcon.CreateCommand();
+ // requires a table to be created named employee
+ // with columns firstname and lastname
+ // such as,
+ // CREATE TABLE employee (
+ // firstname varchar(32),
+ // lastname varchar(32));
+ string sql =
+ "SELECT firstname, lastname " +
+ "FROM employee";
+ dbcmd.CommandText = sql;
+ IDataReader reader = dbcmd.ExecuteReader();
+ while(reader.Read()) {
+ string FirstName = reader["firstname"];
+ string LastName = reader["lastname"];
+ Console.WriteLine("Name: " +
+ FirstName + " " + LastName);
+ }
+ // clean up
+ reader.Close();
+ reader = null;
+ dbcmd.Dispose();
+ dbcmd = null;
+ dbcon.Close();
+ dbcon = null;
+ }
+ }
+</pre>
+ </li>
+ <li>Building C# Example:
+ <ul>
+ <li>Save the example to a file, such as, TestExample.cs</li>
+ <li>Build on Linux:
+<pre>
+ mcs TestExample.cs -r System.Data.dll \
+ -r Npgsql.dll
+</pre>
+ </li>
+ <li>Build on Windows via Cygwin:
+<pre>
+ mono C:/cygwin/home/MyHome/mono/install/bin/mcs.exe \
+ TestExample.cs \
+ -lib:C:/cygwin/home/MyHome/mono/install/lib \
+ -r System.Data.dll -r Npgsql.dll
+</pre>
+ </li>
+ </ul>
+ </li>
+ <li>Running the Example:
+<pre>
+mono TestExample.exe
+</pre>
+</li>
+</ul>
+