3 The coordinator for the ADO.NET implementation is <a
4 href="mailto:rodrigo@ximian.com">Rodrigo Moya</a>, with
5 the collaboration of <a href="mailto:danmorg@sc.rr.com">Daniel
10 The current plan to implement ADO.NET is as follows:
12 <b>Step 1:</b> SqlClient:
15 * Implementation of System.Data.SqlClient based on
16 the <a href="http://www.postgresql.org/idocs/">PostgreSQL C API</a>
18 * Once the <a href="http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemdatasqlclient.asp?frame=true">System.Data.SqlClient</a>
19 code is functional and is usable by other people, we willl move it to
20 System.Data.PostgreSQL, and will convert the existing
21 System.Data.SqlClient to be just a wrapper around
22 System.Data.PostgreSQL.
26 <b>Step 2:</b> <a href="http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemDataOleDb.asp?frame=true">System.Data.OleDb</a> Provider:
29 * On Unix systems: System.Data.OleDb will use the
30 <a href="http://www.gnome-db.org/">LibGDA</a>
33 LibGDA is a data access engine like ADO/OLE-DB, but for Unix. It is
34 used by Gnome-Db and libgnomedb. There is work under way to get libgda
35 working under Windows by the Gnome-Db developers.
37 * On Windows systems: System.Data.OleDb will use OLE-DB as
38 its engine. It may have the option of using libgda too.
41 <b>Step 3:</b> <a href="http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemdatasqlclient.asp?frame=true">System.Data.SqlClient</a> Provider:
44 * <p>System.Data.SqlClient will then become a managed
45 provider for Microsoft SQL Server, both on Windows and
46 Linux, to be compatible with applications written
47 for the Microsoft .NET Development Framework.
49 <p>Once Step 1 has been completed and the PostgreSQL
50 provider support has been moved to its own place at
51 System.Data.PostgreSQL, we will use
52 <a href="http://www.freetds.org/">FreeTDS</a> as the basis
53 for providing access to Microsoft SQL Server databases.
55 FreeTDS is a C API for Unix and Windows that implements
56 the TDS (Tabular Data Stream) protocol used in accessing
57 Microsoft SQL Server and Sybase databases.
60 <b>Step 4:</b> <a href="http://msdn.microsoft.com/downloads/sample.asp?url=/MSDN-FILES/027/001/668/msdncompositedoc.xml&frame=true">System.Data.Odbc</a> Provider:
63 * We will create a .NET Managaed Provider for ODBC
64 in System.Data.Odbc for those using ODBC.
65 On Unix and Windows, <a href="http://www.unixodbc.org/">unixODBC</a> will be used.
67 unixODBC works on Unix and Windows. Providers exist for
68 Oracle, Microsoft SQL Server and Sybase via FreeTDS,
69 MySQL, PostgreSQL, IBM DB2, Interbase, and others.
73 <b>Step 5:</b> Other System.Data providers:
76 * The idea in Microsoft .NET System.Data seems to be to have
77 a managed provider for each supported DBMS. So, apart
78 from System.Data.OleDb (generic) and System.Data.SqlClient,
79 we'll need to have System.Data.MySQL,
80 System.Data.Oracle, and System.Data.PostgreSQL. Others,
81 of course, are welcomed.
86 <p>We are still working on Step 1, but we are planning the other steps.
88 <p>We are able to do simple CREATE TABLE, DROP TABLE, UPDATE, INSERT, and
89 DELETE SQL commands using the ExecuteNonQuery method in SqlCommand.
91 <p>We are also able to do simple aggregate functions,
92 ie, count(), sum(), min(), and max()
93 in a simple SELECT SQL query using the ExecuteScalar() now.
95 <p>We are also able to retrieve data with a simple SELECT SQL query
96 using ExecuteReader() which returns a SqlDataReader. We are able to
97 use GetSchemaTable() to get the meta data about the table columns.
98 We are able to Read() to get each row from the result set. We are able to get
99 String data (char, bpchar (character), text, varchar), Int16 (int2 or smallint),
100 Int32 (int4 or integer), Int64 (int8 or bigint), DateTime (time, date, timestamp),
101 Boolean (boolean), Single (float), and Double (double).
102 Other More data types will follow later on.
104 <p>Parameters and stored procedures have not been tested and most likely
107 <p>A lot of functionality in System.Data is missing, but the
108 infrastructure is starting to come together.
110 <p>Need help on the DataSet/DataAdaptor/DataTable/DataRelation/XML
111 functionality so we can integrate with
112 the ASP.NET controls and Windows.Forms.
114 <P>Need to add XML support in System.Data.
116 <p>To compile that test program, you need:
121 * update your mono and mcs sources.
123 * get the files from mcs/class/lib/*.dll and mcs/mcs/mcs*
124 built on windows, and put them on your
125 linux machine at, for example, ~/mono/install/bin and
128 * compile the test program along with the System.Data,
129 System.Data.Common, System.Data.SqlClient, and
130 System.Data.SqlTypes. The test program to use is PostgreTest.cs
135 <p>In order to test System.Data.SqlClient, you will need to have
136 access to a remote PostgreSQL DBMS, or you will have to install
137 one locally. PostgreSQL is the DBMS used for the initial
138 implementation of System.Data.SqlClient.
140 <p>Why? Because it is open source, has a client
141 library that is easy to use, PostgreSQL on Windows is easy to install on
142 Unix and Windows (using the Cygwin install program), not difficult to setup after
143 installation, and it runs under: Linux,
144 Windows (via cygwin and ipc-daemon), Unix, and
145 others. This allowed us to create the
146 System.Data functionality in Mono much quicker.
148 <p>If you plan on using a remote PostgreSQL DBMS Server,
149 than you will need to have the PostgreSQL client software on your
150 local computer that includes libpq.so (pq.dll on Windows).
152 <p>Installation instructions for PostgreSQL DBMS:
159 * It easier to install PostgreSQL on Linux than Windows.
165 * Use the <a href="http://www.cygwin.com/">Cygwin</a> installer to install the PostgreSQL DBMS. It is
166 found in the database category.
168 * <p>Read the file postgres-x.x.README at /usr/doc/Cygwin and read
169 the requirements to install PostgreSQL. Those requirements
170 are included with cygwin except cygipc. A default installtion
171 of cygwin does not install everything you will need, so on the
172 safe side, just include everything when installing cygwin.
174 * <p>The -x.x in postgres-x.x is the version of your PostgreSQL DBMS.
176 * <p>Once Cygwin has installed the PostgreSQL DBMS on your computer,
177 read the file FAQ_MSWIN which is available
178 in /usr/doc/postgres-x.x
180 * <p>Important notes from this file are:
183 <p><b>2.</b> - Install the latest <a href="http://www.neuro.gatech.edu/users/cwilson/cygutils/OBSOLETE/V1.1/cygipc/index.html">CygIPC</a> package.
185 <p>The cygipc package contains the ipc-daemon you will need
186 to run before you can
187 run the PostgreSQL DBMS Server daemon (postmaster) or run
188 initdb which initializes the PostgreSQL database.
190 <p><b>3.</b> The Cygwin bin directory has to be placed in
191 the path before the Windows program directories,
192 for example, C:\cygwin\bin
194 My own note, in the Windows control panel, I set
195 the environment variables PATH to my cygwin /usr/local/bin,
196 /usr/bin, and /bin. I also set my LD_LIBRARY_PATH to
197 /usr/local/lib and /usr/lib. For example:
201 PATH=c:\cygwin\usr\local\bin;c:\cygwin\usr\bin;c:\cygwin\bin;
202 LD_LIBRARY_PATH=c:\cygwin\usr\local\lib;c:\cygwin\usr\lib;
205 <p><b>4.</b> Start the ipc-daemon that came with the cygipc package. There
206 are two ways to do this: run it from the command line as:
212 <p>or you can set it up as a Windows service. See the
213 file cygrunsrv.README at /usr/doc/Cygwin on how to do this
214 for ipc-daemon and postmaster. Note the
215 troubleshooting section at the end of
216 the cygrunsrv.README file.
218 <p>To install ipc-daemon as a service,
223 ipc-daemon --install-as-service' (--remove-as-service)
233 <p>Read the installation.html file
234 at /usr/doc/postgresql-x.x/html/installation.html
236 <p>You will see in this file that you will need to
237 run the following commands:
241 mkdir /usr/local/pgsql/data
\r
242 initdb -D /usr/local/pgsql/data
\r
243 postmaster -D /usr/local/pgsql/data >logfile 2>&1 &
\r
248 <p>When you need to connect to the database,
249 you will need ipc-daemon and postmaster running. Start ipc-daemon
250 before any of the command above.
252 <p>psql is a command-line PostgreSQL client tool to
253 enter and run SQL commands and queries.
255 <p>If there is no database user named postgres, create a user named
256 postgres with the following SQL command in the client tool psql:
261 create user postgres with password 'fun2db';
263 <p>The only reason I say this is so you can easily use the System.Data tests
264 without having to change the database, userid, etc.
267 <p>In the path mcs/class/System.Data/Test
268 there is a PostgreSQL test program named
269 PostgreTest.cs. Thanks goes to Gonzalo for creating the original
272 <p>To use it to test System.Data, you
273 modify the file to your PostgreSQL database
274 connection requirements:
278 dbname is the database, ie, test
279 host is the hostname of the PostgreSQL DBMS Server to connect to
280 user is the username, ie, someuser
281 password is the password, ie, mypass1234
284 <p>The connection string is in OLE-DB connection string format. Internally,
285 SqlConnection converts this to the PostgreSQL connection string format.
289 OLE-DB: "host=localhost;dbname=test;user=joe;password=smoe"
290 PostgreSQL: "host=localhost dbname=test user=joe password=smoe"
294 Note that OLE-DB includes the semicolons while PostgreSQL's connection
298 To compile the PostgresTest.cs program, do:
302 mcs PostgresTest.cs -r System.Data
306 To run using mint, do:
310 mint PostgresTest.exe
314 To run using mono, do:
316 mono PostgresTest.exe
319 <p>You should get something like:
323 Administrator@DANPC ~/mono/mcs/class/System.Data/Test
\r
324 $ mcs PostgresTest.cs -r System.Data
\r
326 Administrator@DANPC ~/mono/mcs/class/System.Data/Test
\r
327 $ mint PostgresTest.exe
\r
328 Postgres provider specific tests...
\r
331 Error (don't worry about this one)
\r
332 Create table with all supported types:
\r
334 Insert values for all known types:
\r
336 Select values from the database:
\r
338 dt.Columns.Count: 6
\r
339 * Column Name: int2_value
\r
342 * Column Name: int4_value
\r
345 * Column Name: bigint_value
\r
348 * Column Name: char_value
\r
350 Type: System.String
\r
351 * Column Name: varchar_value
\r
353 Type: System.String
\r
354 * Column Name: text_value
\r
356 Type: System.String
\r
358 Col 0: int2_value - -22
\r
359 Col 1: int4_value - 1048000
\r
360 Col 2: bigint_value - 123456789012345
\r
361 Col 3: char_value - This is a char
\r
362 Col 4: varchar_value - This is a varchar
\r
363 Col 5: text_value - This is a text
\r