2005-01-31 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mcs / class / System.Data / Test / TestSqlDataAdapter.cs
1 //
2 // TestPgSqlDataAdapter - tests PgSqlDataAdapter, DbDataAdapter, DataSet, DataTable,
3 //                      DataRow, and DataRowCollection by retrieving data
4 //
5 // Authors:
6 //      Tim Coleman <tim@timcoleman.com>
7 //      Daniel Morgan <danmorg@sc.rr.com>
8 //
9 // (c)copyright 2002 Tim Coleman
10 // (c)copyright 2002 Daniel Morgan
11 //
12
13 //
14 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
15 //
16 // Permission is hereby granted, free of charge, to any person obtaining
17 // a copy of this software and associated documentation files (the
18 // "Software"), to deal in the Software without restriction, including
19 // without limitation the rights to use, copy, modify, merge, publish,
20 // distribute, sublicense, and/or sell copies of the Software, and to
21 // permit persons to whom the Software is furnished to do so, subject to
22 // the following conditions:
23 // 
24 // The above copyright notice and this permission notice shall be
25 // included in all copies or substantial portions of the Software.
26 // 
27 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
28 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
29 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
30 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
31 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
32 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
33 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 //
35
36 using System;
37 using System.Collections;
38 using System.Data;
39 using Mono.Data.PostgreSqlClient;
40
41 namespace TestSystemDataPgSqlClient 
42 {
43         public class TestPgSqlDataAdapter 
44         {
45                 public static void Test() 
46                 {
47                         string connectionString;
48                         string sqlQuery;
49                         PgSqlDataAdapter adapter;
50                         DataSet dataSet = null;
51
52                         connectionString =
53                                 "host=localhost;" +
54                                 "dbname=test;" +
55                                 "user=postgres";
56                                                 
57                         sqlQuery = "select * from pg_tables";
58
59                         System.Console.WriteLine ("new PgSqlDataAdapter...");
60                         adapter = new PgSqlDataAdapter (sqlQuery, 
61                                         connectionString);
62
63                         System.Console.WriteLine ("new DataSet...");
64                         dataSet = new DataSet ();
65
66                         try {
67                                 System.Console.WriteLine("Fill...");
68                                 adapter.Fill (dataSet);
69
70                         }
71                         catch (NotImplementedException e) {
72                                 Console.WriteLine("Exception Caught: " + e);
73                         }               
74                         
75                         System.Console.WriteLine ("get row...");
76                         if (dataSet != null) {
77                                 foreach (DataRow row in dataSet.Tables["Table"].Rows)
78                                         Console.WriteLine("tablename: " + row["tablename"]);
79                                 System.Console.WriteLine("Done.");
80                         }
81
82                 }
83
84                 public static void Main() 
85                 {
86                         Test();
87                 }
88         }
89 }