2 // OdbcTest.cs - Test for the ODBC ADO.NET Provider in System.Data.Odbc
\r
4 // The test works on Windows XP using Microsoft .NET Framework 1.1 Beta
\r
6 // To compile under Windows using Microsoft .NET 1.1
\r
7 // E:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\csc OdbcTest.cs /reference:System.Data.dll
\r
9 // To compile under Windows using Mono:
\r
10 // mcs OdbcTest.cs -r System.Data.dll
\r
12 // I have not tested it on Linux using unixODBC
\r
15 // Daniel Morgan <danmorg@sc.rr.com>
\r
19 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
21 // Permission is hereby granted, free of charge, to any person obtaining
22 // a copy of this software and associated documentation files (the
23 // "Software"), to deal in the Software without restriction, including
24 // without limitation the rights to use, copy, modify, merge, publish,
25 // distribute, sublicense, and/or sell copies of the Software, and to
26 // permit persons to whom the Software is furnished to do so, subject to
27 // the following conditions:
29 // The above copyright notice and this permission notice shall be
30 // included in all copies or substantial portions of the Software.
32 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
33 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
34 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
35 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
36 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
37 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
38 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
43 using System.Data.Odbc;
\r
45 namespace Test.OdbcTest
\r
50 static void Main(string[] args)
\r
52 OdbcConnection dbcon = new OdbcConnection();
\r
53 // connection string to a Microsoft SQL Server 2000 database
\r
54 // that does not use a DSN
\r
55 //dbcon.ConnectionString =
\r
56 // "DRIVER={SQL Server};" +
\r
57 // "SERVER=(local);" +
\r
58 // "Trusted_connection=true;" +
\r
59 // "DATABASE=pubs;";
\r
61 // connection string that uses a DSN.
\r
62 dbcon.ConnectionString =
\r
63 "DSN=LocalServer;UID=sa;PWD=";
\r
67 OdbcCommand dbcmd = new OdbcCommand();
\r
68 dbcmd.Connection = dbcon;
\r
69 dbcmd.CommandType = CommandType.Text;
\r
70 dbcmd.CommandText = "SELECT lname FROM employee";
\r
72 OdbcDataReader reader;
\r
73 reader = (OdbcDataReader) dbcmd.ExecuteReader();
\r
75 while(reader.Read()) {
\r
76 Console.WriteLine("Last Name: " + reader[0].ToString());
\r