2010-04-16 Sebastien Pouliot <sebastien@ximian.com>
[mono/afaerber.git] / web / tdsclient
blob2c58aea698f10ae8c6222e894ffb5005163eece4
1 * TDS Generic Provider
3 <ul>
4         <li>ADO.NET Provider for older Sybase and Microsoft SQL Server databases</li>
6         <li>Exists in namespace Mono.Data.TdsClient and assembly Mono.Data.TdsClient</li>
7         
8         <li>Created by Tim Coleman</li>
9         
10         <li>Used the <a href="http://www.freetds.org/">FreeTDS</a> and 
11         <a href="http://jtds.sourceforge.net/">jTDS</a> projects as resources.</li>
12         
13         <li>Implemented in 100% C#</li>
14         
15         <li>Is similar to the Mono.Data.SybaseClient and System.Data.SqlClient providers.</li>
16         
17         <li>Requires the assembly Mono.Data.Tds.dll which implements the TDS protocol in 100% C#.</li>
18         
19         <li>Uses TDS Protocol Version 4.2 by default</li>
20         
21         <li>Bugs with Mono or the data provider should be reported 
22         in Mono's Bugzilla <a href="http://bugzilla.ximian.com/">here</a>.  If you
23         do not have Bugzilla user account, it is free 
24         and easy to 
25         create one <a href="http://bugzilla.ximian.com/createaccount.cgi">here</a>.</li>
27 </ul>
29 ** Current Status
32 <ul>
33         <li>Only builds on Windows currently due to mcs does not support modules and mcs
34         has problems with code that is internal.</li>
35         
36         <li>Able to connect to Microsoft SQL Server and Sybase databases</li>
37         
38         <li>SQL commands can be executed
39         via ExecuteNonQuery() of a TdsCommand.</li>
40         
41         <li>SQL aggregates can be executed and a single row and single column
42         result can be retrieved via ExecuteScalar() of a TdsCommand</li>
43         
44         <li>SQL queries can be executed via ExecuteReader() and results 
45         can be retrieved via TdsDataReader.</li>
46         
47         <li>a DataTable with schema info about a result can be gotten via GetSchemaTable()
48         in a TdsDataReader</li>
49         
50         <li>Data can be filled in a DataTable in a DataSet via a TdsDataAdapter</li>
51 </ul>
53 ** Action plan
55 <ul>
56         <li>Connection timeouts is being developed now.</li>
58         <li>TODO</li>
59 </ul>
61 ** Testing
63 <ul>
64         <li>Have a working mono and mcs installed</li>
65         
66         <li>Have access to a Sybase or Microsoft SQL Server database 
67         or either download it:
68                 <ul>
69                         <li><a href="http://www.microsoft.com/sql/default.asp">Microsoft SQL Server</a></li>
70                         <li><a href="http://www.sybase.com/downloads">Sybase</a></li>
71                 </ul>
72         </li>
73         <li>If using Microsoft SQL Server 2000, make sure
74         you are using at least Service Pack 3 for Microsoft SQL Server 2000</li>
75         
76         <li>Located at mcs/class/System.Data/Test is a test for System.Data.SqlClient
77         named SqlTest.cs and you could use this as a basis for your test.</li>
78         
79                 <li>Has a connection string format:
80 <pre>
81  Server=hostname;Database=databaseName;User ID=userid;Password=password
82 </pre>
83         </li>
84         <li>The Server part can be used two ways:
85                 <ul>
86                         <li>hostname - "Server=MYHOST"</li>
87                         <li>hostname,port - "Server=MYHOST,1533"</li>
88                 </ul>
89         </li>
90         
91         <li>C# Example:
92 <pre>
93  using System;
94  using System.Data;
95  using Mono.Data.TdsClient;
97  public class Test 
98  {
99     public static void Main(string[] args)
100     {
101        string connectionString = 
102           "Server=localhost;" +
103           "Database=pubs;" +
104           "User ID=myuserid;" +
105           "Password=mypassword;";
106        IDbConnection dbcon;
107        dbcon = new TdsConnection(connectionString);
108        dbcon.Open();
109        IDbCommand dbcmd = dbcon.CreateCommand();
110        string sql = 
111            "SELECT fname, lname " +
112            "FROM employee";
113        dbcmd.CommandText = sql;
114        IDataReader reader = dbcmd.ExecuteReader();
115        while(reader.Read()) {
116             string FirstName = (string) reader["fname"];
117             string LastName = (string) reader["lname"];
118             Console.WriteLine("Name: " + 
119                  FirstName + " " + LastName);
120        }
121        // clean up
122        reader.Close();
123        reader = null;
124        dbcmd.Dispose();
125        dbcmd = null;
126        dbcon.Close();
127        dbcon = null;
128     }
130 </pre>
131         </li>
132         <li>Building C# Example:
133         <ul>
134                 <li>Save the example to a file, such as, TestExample.cs</li>
135                 <li>Build on Linux:
136 <pre>
137         mcs TestExample.cs -r System.Data.dll \
138             -r Mono.Data.TdsClient.dll
139 </pre>
140                 </li>
141                 <li>Build on Windows via Cygwin:
142 <pre>
143         mono C:/cygwin/home/MyHome/mono/install/bin/mcs.exe \
144              TestExample.cs \
145              -lib:C:/cygwin/home/MyHome/mono/install/lib \
146              -r System.Data.dll -r Mono.Data.TdsClient.dll
147 </pre>
148                 </li>
149         </ul>
150         </li>
151         <li>Running the Example:
152 <pre>
153 mono TestExample.exe
154 </pre>
155         </li>
156 </ul>