2010-04-16 Sebastien Pouliot <sebastien@ximian.com>
[mono/afaerber.git] / web / sybase
blob85deca1a67cd8afd5c38660f407d40e5db0d6f81
1 * Sybase Data Provider
3 <ul>
4         <li>ADO.NET Provider for Sybase SQL Server databases</li>
6         <li>Exists in namespace Mono.Data.SybaseClient and assembly Mono.Data.SybaseClient</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.TdsClient 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 5.0</li>
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>
28 </ul>
30 ** Current Status
31         
32 <ul>    
33         <li>Able to connect to Sybase databases</li>
34         
35         <li>SQL commands can be executed
36         via ExecuteNonQuery() of a SybaseCommand.</li>
37         
38         <li>SQL aggregates can be executed and a single row and single column
39         result can be retrieved via ExecuteScalar() of a SybaseCommand</li>
40         
41         <li>SQL queries can be executed via ExecuteReader() and results 
42         can be retrieved via SybaseDataReader.</li>
43         
44         <li>a DataTable with schema info about a result can be gotten via GetSchemaTable()
45         in a SybaseDataReader</li>
46         
47         <li>Data can be filled in a DataTable in a DataSet via a SybaseDataAdapter</li>
48 </ul>
50 ** Action plan
52 <ul>
53         <li>Connection timeouts is being developed now.
54         
55         <li>Needs more testing...
57 </ul>
59 ** Testing
61 <ul>
62         <li>Have a working mono and mcs installed</li>
63         
64         <li>Have access to a Sybase database 
65         or either download it:
66                 <ul>
67                         <li><a href="http://www.sybase.com/downloads">Sybase</a></li>
68                 </ul>
69         </li>
70         
71         <li>Located at mcs/class/System.Data/Test is a test for System.Data.SqlClient
72         named SqlTest.cs and you could use this as a basis for your test.</li>
73         
74         <li>Has a connection string format:
75 <pre>
76  Server=hostname;Database=databaseName;User ID=userid;Password=password
77 </pre>
78         </li>
79         <li>The Server part can be used two ways:
80                 <ul>
81                         <li>hostname - "Server=MYHOST"</li>
82                         <li>hostname,port - "Server=MYHOST,1533"</li>
83                 </ul>
84         </li>
85                 
86         <li>C# Example:
87 <pre>
88  using System;
89  using System.Data;
90  using Mono.Data.SybaseClient;
92  public class Test 
93  {
94     public static void Main(string[] args)
95     {
96        string connectionString = 
97           "Server=localhost;" +
98           "Database=pubs;" +
99           "User ID=myuserid;" +
100           "Password=mypassword;";
101        IDbConnection dbcon;
102        dbcon = new SybaseConnection(connectionString);
103        dbcon.Open();
104        IDbCommand dbcmd = dbcon.CreateCommand();
105        string sql = 
106             "SELECT fname, lname " + 
107             "FROM employee";
108        dbcmd.CommandText = sql;
109        IDataReader reader = dbcmd.ExecuteReader();
110        while(reader.Read()) {
111             string FirstName = (string) reader["fname"];
112             string LastName = (string) reader["lname"];
113             Console.WriteLine("Name: " + 
114                  FirstName + " " + LastName);
115        }
116        // clean up
117        reader.Close();
118        reader = null;
119        dbcmd.Dispose();
120        dbcmd = null;
121        dbcon.Close();
122        dbcon = null;
123     }
125 </pre>
126         </li>
127         <li>Building C# Example:
128         <ul>
129                 <li>Save the example to a file, such as, TestExample.cs</li>
130                 <li>Build on Linux:
131 <pre>
132         mcs TestExample.cs -r System.Data.dll \
133             -r Mono.Data.SybaseClient.dll
134 </pre>
135                 </li>
136                 <li>Build on Windows via Cygwin:
137 <pre>
138         mono C:/cygwin/home/MyHome/mono/install/bin/mcs.exe \
139              TestExample.cs \
140              -lib:C:/cygwin/home/MyHome/mono/install/lib \
141              -r System.Data.dll -r Mono.Data.SybaseClient.dll
142 </pre>
143                 </li>
144         </ul>
145         </li>
146         <li>Running the Example:
147 <pre>
148 mono TestExample.exe
149 </pre>
150         </li>
152 </ul>