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