oledb 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. * OLE DB Provider
  2. <ul>
  3. <li> Provides a OleDb-like provider for Mono
  4. using <a href="http://www.gnome-db.org/">GDA</a> as the data access layer.</li>
  5. <li> Exists in namespace System.Data.OleDb and assembly System.Data</li>
  6. <li>Created by Rodrigo Moya</li>
  7. <li>LibGDA has providers for:</li>
  8. <ul>
  9. <li><a href="http://www.mysql.com/">MySQL</a></li>
  10. <li><a href="http://www.postgresql.org/">PostgreSQL</a></li>
  11. <li>XML</li>
  12. <li>ODBC (via <a href="http://www.unixodbc.org/">unixODBC</a>)</li>
  13. <li><a href="http://www.oracle.com/">Oracle</a></li>
  14. <li><a href="http://www.borland.com/products/downloads/download_interbase.html">Interbase</a></li>
  15. <li><a href="http://www.sybase.com/downloads">Sybase</a> and
  16. <a href="http://www.microsoft.com/sql/default.asp">Microsoft SQL Server</a> (
  17. via <a href="http://www.freetds.org/">FreeTDS</a>)</li>
  18. <li><a href="http://www-3.ibm.com/software/data/db2/">IBM DB2 Universal Database</a></li>
  19. <li><a href="http://www.hwaci.com/sw/sqlite/download.html">SQL Lite</a></li>
  20. <li><a href="http://www.microsoft.com/office/access/default.asp">MS Access</a></li>
  21. (via <a href="http://mdbtools.sourceforge.net/">MDB Tools</a>)</li>
  22. </ul>
  23. </li>
  24. <li>Does not support trusted connections</li>
  25. <li>Bugs with Mono or the data provider should be reported
  26. in Mono's Bugzilla <a href="http://bugzilla.ximian.com/">here</a>. If you
  27. do not have Bugzilla user account, it is free
  28. and easy to
  29. create one <a href="http://bugzilla.ximian.com/createaccount.cgi">here</a>.</li>
  30. </ul>
  31. ** Current Status
  32. <ul>
  33. <li>The OleDb provider is working with libgda (an OLE-DB/ADO data access for Unix).
  34. The C-Sharp bindings to libgda currently work - meaning they can compile, run,
  35. and you can connect to a
  36. PostgreSQL database via libgda via the C-Sharp bindings to libgda.</li>
  37. <li>Basic
  38. functionality (execution of commands, data retrieval, transactions, etc) are
  39. now working.</li>
  40. <li>An inital implementation of GetSchemaTable() for
  41. the OleDbDataReader has been checked into cvs. GetSchemaTable() isn't correct for OleDb,
  42. but the foundation is there.</li>
  43. </ul>
  44. ** Action Plan
  45. <ul>
  46. <li>Current focus is on filling up the missing pieces (Data adapters
  47. mainly) and schema support.</li>
  48. <li>We need help building libgda on Windows though. libgda
  49. builds find on linux though.</li>
  50. <li>Need to make the OleDb provider compatible with the OleDb provider in Microsoft .NET</li>
  51. </ul>
  52. ** Testing OleDb with libgda's PostgreSQL provider
  53. <ul>
  54. <li>Requires a working mono and mcs</li>
  55. <li>Requires Linux because the OleDb provider uses libgda and libgda only
  56. works on Linux.</li>
  57. <li>Connection String format: "Provider=providerName;...". providerName is the
  58. name of the Provider you use, such as, PostgreSQL, MySQL, etc. The elipsis ...
  59. means that the connection parameters are dependent upon the provider being used and
  60. are passed to libgda for connecting. Such paramters, can be: Database, User ID, Password,
  61. Server, etc...</li>
  62. <li>See the test TestOleDb.cs found at mcs/class/System.Data/System.Data.OleDb</li>
  63. <li>C# Example for Mono's System.Data.OleDb:
  64. <pre>
  65. using System;
  66. using System.Data;
  67. using System.Data.OleDb;
  68. public class Test
  69. {
  70. public static void Main(string[] args)
  71. {
  72. // there is a libgda PostgreSQL provider
  73. string connectionString =
  74. "Provider=PostgreSQL;" +
  75. "Addr=127.0.0.1;" +
  76. "Database=test;" +
  77. "User ID=postgres;" +
  78. "Password=fun2db";
  79. IDbConnection dbcon;
  80. dbcon = new OleDbConnection(connectionString);
  81. dbcon.Open();
  82. IDbCommand dbcmd = dbcon.CreateCommand();
  83. // requires a table to be created named employee
  84. // with columns firstname and lastname
  85. // such as,
  86. // CREATE TABLE employee (
  87. // firstname varchar(32),
  88. // lastname varchar(32));
  89. string sql =
  90. "SELECT firstname, lastname " +
  91. "FROM employee";
  92. dbcmd.CommandText = sql;
  93. IDataReader reader = dbcmd.ExecuteReader();
  94. while(reader.Read()) {
  95. string FirstName = (string) reader["firstname"];
  96. string LastName = (string) reader["lastname"];
  97. Console.WriteLine("Name: " +
  98. FirstName + " " + LastName);
  99. }
  100. // clean up
  101. reader.Close();
  102. reader = null;
  103. dbcmd.Dispose();
  104. dbcmd = null;
  105. dbcon.Close();
  106. dbcon = null;
  107. }
  108. }
  109. </pre>
  110. </li>
  111. <li>Building C# Example:
  112. <ul>
  113. <li>Save the example to a file, such as, TestExample.cs</li>
  114. <li>Build on Linux:
  115. <pre>
  116. mcs TestExample.cs -r System.Data.dll
  117. </pre>
  118. </li>
  119. <li>Build on Windows via Cygwin:
  120. <pre>
  121. mono C:/cygwin/home/MyHome/mono/install/bin/mcs.exe \
  122. TestExample.cs \
  123. -lib:C:/cygwin/home/MyHome/mono/install/lib \
  124. -r System.Data.dll
  125. </pre>
  126. </li>
  127. </ul>
  128. </li>
  129. <li>Running the Example:
  130. <pre>
  131. mono TestExample.exe
  132. </pre>
  133. </li>
  134. </ul>