| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- //
- // TestSqlDataAdapter - tests SqlDataAdapter, DbDataAdapter, DataSet, DataTable,
- // DataRow, and DataRowCollection by retrieving data
- //
- // Note: it currently causes an NotImplementException for SqlCommand::NextResult()
- //
- // Authors:
- // Tim Coleman <[email protected]>
- // Daniel Morgan <[email protected]>
- //
- // (c)copyright 2002 Tim Coleman
- // (c)copyright 2002 Daniel Morgan
- //
- using System;
- using System.Collections;
- using System.Data;
- using System.Data.SqlClient;
- namespace TestSystemDataSqlClient
- {
- public class TestSqlDataAdapter
- {
- public static void Test()
- {
- string connectionString;
- string sqlQuery;
- SqlDataAdapter adapter;
- DataSet dataSet = null;
- connectionString =
- "host=localhost;" +
- "dbname=test;" +
- "user=postgres";
-
- sqlQuery = "select * from pg_tables";
- System.Console.WriteLine ("new SqlDataAdapter...");
- adapter = new SqlDataAdapter (sqlQuery,
- connectionString);
- System.Console.WriteLine ("open connection...");
- adapter.SelectCommand.Connection.Open ();
-
- System.Console.WriteLine ("new DataSet...");
- dataSet = new DataSet ();
- try {
- System.Console.WriteLine("Fill...");
- adapter.Fill (dataSet);
- }
- catch (NotImplementedException e) {
- Console.WriteLine("Exception Caught: " + e);
- }
-
- System.Console.WriteLine ("get row...");
- if (dataSet != null) {
- foreach (DataRow row in dataSet.Tables["Table"].Rows)
- Console.WriteLine("tablename: " + row["tablename"]);
- System.Console.WriteLine("Done.");
- }
- }
- public static void Main()
- {
- Test();
- }
- }
- }
|