Welcome to mirror list, hosted at ThFree Co, Russian Federation.

odbc « web - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/web/odbc
blob: 80143fcb7eb92bdda8e45dec4acab847a06bd097 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
* ODBC Data Provider

<ul>

	<li>ADO.NET Data Provider for Data Sources 
	that have <a href="http://www.microsoft.com/data/odbc/">ODBC</a> support.</li>

	<li>Exists in namespace System.Data.Odbc and assembly System.Data</li>
	
	<li>Works on Windows and Linux. Should have no problems working on UNIX too.</li>
	
	<li>Works on Windows via the native Windows odbc32.dll</li>
	
	<li>Works on Linux via:
	
	<ul>
		<li><a href="http://www.unixodbc.org/">unixODBC</a> which has 
			commercial support 
			from <a href="http://www.easysoft.com/">Easysoft</a></li>
			
		<li><a href="http://www.iodbc.org/">iODBC</a> which has 
		    commercial support 
		    from <a href="http://oplweb.openlinksw.com:8080/download/">OpenLink Software</a></li>
	</ul>
	
	<li>List of unixODBC <a href="http://www.unixodbc.org/drivers.html">drivers</a>
	
	<li>List of <a href="http://www.sqlsummit.com/odbcvend.htm">ODBC Vendors</a>
	
	<li>ODBC can connect to various databases which has an ODBC driver installed:
	<ul> 
		  <li><a href="http://www.mysql.com/">MySQL</a></li>
		  <li><a href="http://www.postgresql.org/">PostgreSQL</a></li>
		  <li><a href="http://www.oracle.com/">Oracle</a></li>
		  <li><a href="http://www.borland.com/products/downloads/download_interbase.html">Interbase</a></li>
		  <li><a href="http://www.sybase.com/downloads">Sybase</a> (
		  via <a href="http://www.freetds.org/">FreeTDS</a> on UNIX)</li>
		  <li><a href="http://www.microsoft.com/sql/default.asp">Microsoft SQL Server</a> (
		  via <a href="http://www.freetds.org/">FreeTDS</a> on UNIX)</li>
		  <li><a href="http://www-3.ibm.com/software/data/db2/">IBM DB2 Universal Database</a></li>
		  <li><a href="http://www.microsoft.com/office/access">MS Access</a>
		  (via <a href="http://mdbtools.sourceforge.net/">MDB Tools</a> on UNIX)</li>
	</ul>
		
	<li>ODBC Provider created by Brian Ritchie.</li>
	
	<li>Does not support trusted connections</li>
	
</ul>
	
** Current Status

<ul>
	<li>Can Connect on:
	<ul>
		<li>Windows via native Windows odbc32.dll</a></li>
		<li>Linux via:
		<ul>
			<li>unixODBC's libodbc.so</li>
			<li>iODBC's libiodbc.so</li>
		</ul>
		</li>
	</ul>
	</li>
	
	<li>Various databases have been tested using their
	   ODBC drivers: MySQL, PostgreSQL, Oracle, IBM DB2, and Microsoft SQL Server</li>
	   
	<li>Can execute non-query commands via ExecuteNonQuery of a OdbcCommand</li>
	
	<li>Can execute aggreates and retrieve a single row single column result via
	ExecuteScalar of a OdbcCommand</li>
	
	<li>Can execute queries via ExecuteReader of a OdbcCommand and 
	retrieve results using an OdbcDataReader</li>
	
	<li>Can get a DataTable containing schema info via GetSchemaTable() in a OdbcDataReader</li>
	
	<li>Can Fill a DataTable in a DataSet via an OdbcDataAdapter</li>
	
	<li>Works in SQL#, but Column names don't show up correctly.</li>
	
	<li>Bugs with Mono or the data provider should be reported 
	in Mono's Bugzilla <a href="http://bugzilla.ximian.com/">here</a>.  If you
	do not have Bugzilla user account, it is free 
	and easy to 
	create one <a href="http://bugzilla.ximian.com/createaccount.cgi">here</a>.</li>

	
</ul>
	
** Action Plan

<ul>
	
	<li>Fixing bugs
	
	<li>Testing with other setups
</ul>

** Testing ODBC provider with IBM DB2 Universal Database

<ul>
	<li>You need a working mono and mcs</li>
	
	<li>For Unix, you will need unixODBC or iODBC installed</li>
	
	<li>Have acess to a <a href="http://www-306.ibm.com/software/data/db2/">IBM DB2 Universal Database</a> or
	you can download from IBM</li>
	
	<li>Read these web pages about Unix, ODBC, and IBM DB2

	<ul>
		<li><a href="http://www.unixodbc.com/doc/db2.html">unixODBC web page about IBM DB2</a></li>
		<li><a href="http://www-306.ibm.com/software/data/db2/udb/ad/v8/cli/t0010406.htm">IBM web page about unixODBC and DB2</a></li>
	</ul>
	</li>
	
	<li>The ODBC provider is similar to the <a href="http://www.go-mono.com/ibmdb2.html">IBM DB2</a> provider.</li>
</ul>

** Testing ODBC provider with MySQL

<p>You can test Mono's ODBC provider System.Data.Odbc with the MySQL ODBC driver MyODBC
	
<p><ul>
	<li>Take a look at OdbcTest.cs in mcs/class/System.Data/Test</li>

	<li>Here is a ConnectionString format if you have a DSN setup: 
<pre>
"DSN=dataSetName;UID=myuserid;PWD=mypassword"
</pre>
	</li>
	<li>Here is a ConnectionString format if you do not have a DSN (have not
	gotten this to work though):
<pre>
"DRIVER={MySQL ODBC 3.51 Driver};" +
"SERVER=localhost;DATABASE=test;" +
"UID=myuserid;PASSWORD=mypassword;" +
"OPTION=3";

</pre>
	</li>
	<li>C# Example:
<pre>
 using System;
 using System.Data;
 using System.Data.Odbc;
 
 public class Test 
 {
    public static void Main(string[] args)
    {
		// have an ODBC DSN setup named MYSQLDSN
		// that accesses a MySQL database via
		// MyODBC driver for ODBC with a
		// hostname of localhost and database test
       string connectionString = 
          "DSN=MYSQLDSN;" +
          "UID=myuserid;" +
          "PWD=mypassword";
       IDbConnection dbcon;
       dbcon.Open();
       dbcon = new OdbcConnection(connectionString);
       IDbCommand dbcmd = dbcon.CreateCommand();
       // requires a table to be created named employee
       // with columns firstname and lastname
       // such as,
       //        CREATE TABLE employee (
       //           firstname varchar(32),
       //           lastname varchar(32));
       string sql = 
           "SELECT firstname, lastname " +
           "FROM employee";
       dbcmd.CommandText = sql;
       IDataReader reader = dbcmd.ExecuteReader();
       while(reader.Read()) {
            string FirstName = (string) reader["firstname"];
            string LastName = (string) reader["lastname"];
            Console.WriteLine("Name: " + 
                FirstName + " " + LastName);
       }
       // clean up
       reader.Close();
       reader = null;
       dbcmd.Dispose();
       dbcmd = null;
       dbcon.Close();
       dbcon = null;
    }
 }
</pre>
	</li>
	<li>Building C# Example:
	<ul>
		<li>Save the example to a file, such as, TestExample.cs</li>
		<li>Build on Linux:
<pre>
	mcs TestExample.cs -r System.Data.dll
</pre>
		</li>
		<li>Build on Windows via Cygwin:
<pre>
	mono C:/cygwin/home/MyHome/mono/install/bin/mcs.exe \
	     TestExample.cs \
	     -lib:C:/cygwin/home/MyHome/mono/install/lib \
	     -r System.Data.dll
</pre>
		</li>
	</ul>
	</li>
	<li>Running the Example:
<pre>
mono TestExample.exe
</pre>
	</li>
	
</ul>