2010-04-16 Sebastien Pouliot <sebastien@ximian.com>
[mono/afaerber.git] / web / ado-net
blob0095d79ef79996374030641fce45c5c8a01272ac
1 * ADO.NET
3 ** Data Access in Mono
5 <ul>
6         <li>Today, our goal is to be compatible with  .NET 1.1 and .NET 1.0.  We also would like
7    to extend data access beyond what is included with .NET 1.0 and .NET 1.1,
8    such as, include access to more databases, such as, PostgreSQL and MySQL,
9    but also provide classes that help in creating data source-agnostic code, such as, 
10    Mono.Data.ProviderFactory.</li>
11    
12    <li>In the future, we would like to be compatible with .NET 1.2. This includes features 
13    like <a href="http://longhorn.msdn.microsoft.com/lhsdk/ndp/daconworkingwithobjectspacesarchitecture.aspx">ObjectSpaces</a></li>
14         
15 </ul>
17 ** Bugs and Feature Requests
19 <ul>
21         <li>Bugs with Mono or any data provider in Mono should be reported 
22             in Mono's Bugzilla <a href="http://bugzilla.ximian.com/">here</a>.  If you
23             do not have a Bugzilla user account, it is free 
24             and easy to create 
25             one <a href="http://bugzilla.ximian.com/createaccount.cgi">here</a>.</li>
26         
27         <li>Any requests for new features or missing functionality
28             can entered as a bug in Bugzilla too</li>
30 </ul>
31         
32 ** ADO.NET Data Providers
33         
34 <p>Mono has many ADO.NET Data Providers to get you connected:
35                         
36 <ul>
37         <li><a href="http://www.go-mono.com/ibmdb2.html">IBM DB2 Universal Database</a></li>
38         <li><a href="http://www.go-mono.com/mysql.html">MySQL</a></li>
39         <li><a href="http://www.go-mono.com/odbc.html">ODBC</a></li>
40         <li><a href="http://www.go-mono.com/oracle.html">Oracle</a></li>
41         <li><a href="http://www.go-mono.com/oledb.html">OLE DB</a></li>
42         <li><a href="http://www.go-mono.com/postgresql.html">PostgreSQL</a></li>
43         <li><a href="http://www.go-mono.com/sqlclient.html">Microsoft SQL Server</a></li>
44         <li><a href="http://www.go-mono.com/sqlite.html">SQL Lite</a></li>
45         <li><a href="http://www.go-mono.com/sybase.html">Sybase</a></li>
46         <li><a href="http://www.go-mono.com/tdsclient.html">Older Microsoft SQL Server and Sybase databases</a></li>
47 </ul>
49 <p>External Projects that have created ADO.NET Providers that work on Mono:
51 <ul>
53         <li><a href="http://www.go-mono.com/firebird.html">Firebird Interbase</a></li> is a
54            Firebird SQL Managed data provider. It can be used with Interbase databases too.  It
55            is written in 100%C# and does not require a client library. Works on .NET and Mono.</a>
56         <li><a href="http://gborg.postgresql.org/project/npgsql/projdisplay.php">Npgsql</a> is a 
57            PostgreSQL Managed data provider written 
58            in 100% C#, does not require a client library, and works on .NET and Mono</li>
59         <li><a href="http://sourceforge.net/projects/mysqlnet/">MySQLNet</a> is a 
60            MySQL Managed data provider written in 100% C#, does not
61            require a client library, and works on .NET and Mono</li>
62 </ul>
64 ** Tools
66 <p>Some tools that can be used for ADO.NET and other technologies (ASP.NET, XML, etc).
68 <ul>
69         <li>sqlsharp.exe
70                 <ul>
71                         <li>SQL# is a command line query tool included with Mono to enter and execute SQL statements</li>
72                 </ul>
73         </li>
74         <li>xsd.exe
75                 <ul>
76                         <li>XML Schema Definition tool</li>
77                                 <ul>
78                                         <li><b>XDR to XSD</b> - used to generate an XML schema from an XDR (XML Data Reduced schema) file. \r
79                                                 XDR was used by Microsoft prior to XSD becoming a W3C recommendation.  So, this needs\r
80                                                 to be supported for legacy reasons</li>\r
81                                         <li><b>XML to XSD</b> - used to generate an XML schema from an XML file</li> \r
82                                         <li><b>XSD to DataSet</b> - used to generate DataSet classes from an XSD schema file.  The\r
83                                                 DataSet classes created can then be used with XML data</li>\r
84                                         <li><b>XSD to Classes</b> - used to generate classes from an XSD schema file. The \r
85                                                 classes created can be used with System.XML.Serialization.XMLSerializer \r
86                                                 to read and write XML code that follows the schema</li>\r
87                                         <li><b>Classes to XSD</b> - used to generate an XML schema \r
88                                                 from type(s) in a assembly file. The \r
89                                                 XML schema created by the tool defines the XML format used \r
90                                                 by System.XML.Serialization.XMLSerializer</li>\r
91                                 </ul>\r
92                         </li>\r
93                 </ul>\r
94         </li>
95 </ul>
97 ** Extra Classes in Mono ADO.NET
99  <p>An ADO.NET <a href="http://www.go-mono.com/provider-factory.html">Provider Factory</a> 
100     was created by Brian Ritchie.  The 
101         Provider Factory is a way to dynamically create
102         connections, commands, parameters, and data adapters based on configuration 
103         information.
104         
105 ** Database Access from ASP.NET
106         <ul>
107                 <li>Take a look at xsp in cvs and look at the examples in test: dbpage1.aspx
108                 and dbpage2.aspx:
109                         <ul>
110                                 <li>Notice that the namespace System.Data is imported via <b>import</b></li>
111                                 <li>A NameValueCollection is gotten using ConfigurationSettings.AppSetings. These
112                                 settings are gotten from the file server.exe.config which is a XML file.   The XML
113                                 file has a section appSettings.  In the appSettings section, you have keys 
114                                 for DBProviderAssembly, DBConnectionType, and DBConnectionString.
115                                 <ul>
116                                         <li><b>DBProviderAssembly</b> is the assembly of the ADO.NET provider.  
117                                               For example: 
118                                               "ByteFX.Data"</li>
119                                         <li><b>DBConnectionType</b> is the System.Type of the class that 
120                                               implements System.Data.IDbConnection that is found
121                                           in the DBProviderAssembly.  
122                                           For example: 
123                                           "ByteFX.Data.MySqlConnection"</li> 
124                                     <li><b>DBConnectionString</b> is the ConnectionString to set to the
125                                           IDbConnection object to use in opening a connection to a data source.
126                                           For Example: 
127                                           "hostaddr=127.0.0.1;user=monotest;password=monotest;dbname=monotest"</li>
128                                 </ul>
129                                 <li>The function GetConnectionData() gets the database provider assembly, connection type,
130                                 and connection string parameters if they exist; otherwise, it uses default values.  This is
131                                 done during the loading of the web page.</li>
132                                 <li>With the connection parameters, the assembly is loaded, the connection type is verified that
133                                 it implements IDbConnection and an instance of the class can be created, creates a instance
134                                 of the class, sets the connection string, and opens the connection.</li>
135                         </ul>
136                 </li>
137         </ul>
139 ** Testing
141 <ul>
142         <li>Testing connection-oriented classes are done 
143         via the provider specific tests
144         found in the mcs source at mcs/class</br>
145                 <table border=1>        
146                         <tr>
147                                 <td><b>Name</b></td>
148                                 <td><b>Assembly /</br> Namespace</b></td>
149                                 <td><b>Test</b></td>    
150                         </tr>           
151                         
152                         <tr>
153                                 <td>Microsoft</br> SQL</br> Server</br></td>
154                                 <td>System.Data /</br> System.Data.SqlClient</td>
155                                 <td>SqlTest.cs at</br> System.Data/Test</td>
156                         </tr>
158                         <tr>
159                                 <td>PostgreSQL</br> (Npgsql)</td>
160                                 <td>Npgsql /</br> Npgsql</td>
161                                 <td>*.cs at</br> Npgsql/Test</td>
162                         </tr>
164                         <tr>
165                                 <td>Oracle</br> (Mono)</td>
166                                 <td>System.Data.OracleClient /</br> System.Data.OracleClient</td>
167                                 <td>TestOracleClient.cs at</br> System.Data.OracleClient/Test</td>
168                         </tr>
170                         <tr>
171                                 <td>ODBC</br> (Mono)</td>
172                                 <td>System.Data.Odbc /</br> System.Data</td>
173                                 <td>OdbcTest.cs (to connect to MS SQL Server)at</br> System.Data/Test</td>
174                         </tr>
175                         
176                 </table>
177         
179         <li><a href="http://www.go-mono.com/testing.html">Testing non-connection classes</a> are 
180         done via mono's modified version of NUnit.
181                 <ul>
182                         <li>To run all the NUnit tests for Mono, you need the mcs source.  cd to the root
183                         of the mcs source.  To run it:
184                                 <ul>
185                                         <li>make test</li>
186                                 </ul>
187                         </li>
188                         <li>If you just want to run the NUnit tests for System.Data, you would cd into
189                         the mcs source at class/System.Data/Test and run it:
190                                 <ul>
191                                         <li>make test</li>
192                                 </ul>
193                         </li>
194                 </ul>
195         </li>
196                 
197 </ul>