2 // Test/SqlDataRead.cs
\r
4 // Test to do read a simple forward read only record set.
\r
5 // Using SqlCommand.ExecuteReader() to return a SqlDataReader
\r
6 // which can be used to Read a row
\r
7 // and Get a String or Int32.
\r
10 // Daniel Morgan <danmorg@sc.rr.com>
\r
12 // (C) 2002 Daniel Morgan
\r
15 namespace TestSystemDataSqlClient {
\r
18 using Mono.Data.MySql;
\r
20 class TestSqlDataReader {
\r
23 static void Main(string[] args) {
\r
24 Console.WriteLine("Started.");
\r
26 String connectionString = null;
\r
30 MySqlConnection con;
\r
31 Console.WriteLine("Create MySQL Connection...");
\r
32 con = new MySqlConnection(connectionString);
\r
33 Console.WriteLine("Open the connection...");
\r
37 sql = "select * from db";
\r
39 Console.WriteLine("Create command...");
\r
41 cmd = con.CreateCommand();
\r
43 cmd.CommandText = sql;
\r
45 MySqlDataReader reader;
\r
46 Console.WriteLine("ExecuteReader...");
\r
47 reader = cmd.ExecuteReader();
\r
50 Console.WriteLine("Reading data...");
\r
51 while(reader.Read()){
\r
53 Console.WriteLine("Row: " + row);
\r
54 for(int col = 0; col < reader.FieldCount; col++) {
\r
55 Console.WriteLine(" Field: " + col);
\r
57 Console.WriteLine(" Name: " +
\r
58 reader.GetName(col));
\r
59 Console.WriteLine(" Value: " +
\r
60 reader.GetValue(col));
\r
63 Console.WriteLine("Clean up...");
\r
72 Console.WriteLine("Done.");
\r