- <p>
- <ul>
- <li><b>dbname</b> database, ie., test</li>
- <li><b>host</b> hostname of the PostgreSQL DBMS Server to connect to, ie., localhost</li>
- <li><b>user</b> username, ie., someuser</li>
- <li><b>password</b> password, ie., mypass1234</li>
- </ul>
-
- <p>The connection string is in OLE-DB connection string format. Internally,
- SqlConnection converts this to the PostgreSQL connection string format.
-
- <p>
-<pre>
- OLE-DB: "host=localhost;dbname=test;user=joe;password=smoe"
-PostgreSQL: "host=localhost dbname=test user=joe password=smoe"
-</pre>
-
- <p>
- Note that OLE-DB includes the semicolons while PostgreSQL's connection
- string does not.
-
- <p>
- To compile the PostgresTest.cs program, do:
-
- <p>
-<pre>
-mcs PostgresTest.cs -r System.Data.dll
-</pre>
-
- <p>
- To run using mint, do:
-
- <p>
-<pre>
-mint PostgresTest.exe
-</pre>
-
- <p>
- To run using mono, do:
-<pre>
-mono PostgresTest.exe
-</pre>
-
- <p>Below, I show how the output from PostgresTest. I have omitted a lot
- of the meta data for the columns except two columns. The classes
- used were from System.Data.SqlClient and were used to connect to a
- PostgreSQL database and retrieve data.
-
-<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