tdsclient 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. * TDS Generic Provider
  2. <ul>
  3. <li>ADO.NET Provider for older Sybase and Microsoft SQL Server databases</li>
  4. <li>Exists in namespace Mono.Data.TdsClient and assembly Mono.Data.TdsClient</li>
  5. <li>Created by Tim Coleman</li>
  6. <li>Used the <a href="http://www.freetds.org/">FreeTDS</a> and
  7. <a href="http://jtds.sourceforge.net/">jTDS</a> projects as resources.</li>
  8. <li>Implemented in 100% C#</li>
  9. <li>Is similar to the Mono.Data.SybaseClient and System.Data.SqlClient providers.</li>
  10. <li>Requires the assembly Mono.Data.Tds.dll which implements the TDS protocol in 100% C#.</li>
  11. <li>Uses TDS Protocol Version 4.2 by default</li>
  12. <li>Bugs with Mono or the data provider should be reported
  13. in Mono's Bugzilla <a href="http://bugzilla.ximian.com/">here</a>. If you
  14. do not have Bugzilla user account, it is free
  15. and easy to
  16. create one <a href="http://bugzilla.ximian.com/createaccount.cgi">here</a>.</li>
  17. </ul>
  18. ** Current Status
  19. <ul>
  20. <li>Only builds on Windows currently due to mcs does not support modules and mcs
  21. has problems with code that is internal.</li>
  22. <li>Able to connect to Microsoft SQL Server and Sybase databases</li>
  23. <li>SQL commands can be executed
  24. via ExecuteNonQuery() of a TdsCommand.</li>
  25. <li>SQL aggregates can be executed and a single row and single column
  26. result can be retrieved via ExecuteScalar() of a TdsCommand</li>
  27. <li>SQL queries can be executed via ExecuteReader() and results
  28. can be retrieved via TdsDataReader.</li>
  29. <li>a DataTable with schema info about a result can be gotten via GetSchemaTable()
  30. in a TdsDataReader</li>
  31. <li>Data can be filled in a DataTable in a DataSet via a TdsDataAdapter</li>
  32. </ul>
  33. ** Action plan
  34. <ul>
  35. <li>Connection timeouts is being developed now.</li>
  36. <li>TODO</li>
  37. </ul>
  38. ** Testing
  39. <ul>
  40. <li>Have a working mono and mcs installed</li>
  41. <li>Have access to a Sybase or Microsoft SQL Server database
  42. or either download it:
  43. <ul>
  44. <li><a href="http://www.microsoft.com/sql/default.asp">Microsoft SQL Server</a></li>
  45. <li><a href="http://www.sybase.com/downloads">Sybase</a></li>
  46. </ul>
  47. </li>
  48. <li>If using Microsoft SQL Server 2000, make sure
  49. you are using at least Service Pack 3 for Microsoft SQL Server 2000</li>
  50. <li>Located at mcs/class/System.Data/Test is a test for System.Data.SqlClient
  51. named SqlTest.cs and you could use this as a basis for your test.</li>
  52. <li>Has a connection string format:
  53. <pre>
  54. Server=hostname;Database=databaseName;User ID=userid;Password=password
  55. </pre>
  56. </li>
  57. <li>The Server part can be used two ways:
  58. <ul>
  59. <li>hostname - "Server=MYHOST"</li>
  60. <li>hostname,port - "Server=MYHOST,1533"</li>
  61. </ul>
  62. </li>
  63. <li>C# Example:
  64. <pre>
  65. using System;
  66. using System.Data;
  67. using Mono.Data.TdsClient;
  68. public class Test
  69. {
  70. public static void Main(string[] args)
  71. {
  72. string connectionString =
  73. "Server=localhost;" +
  74. "Database=pubs;" +
  75. "User ID=myuserid;" +
  76. "Password=mypassword;";
  77. IDbConnection dbcon;
  78. dbcon = new TdsConnection(connectionString);
  79. dbcon.Open();
  80. IDbCommand dbcmd = dbcon.CreateCommand();
  81. string sql =
  82. "SELECT fname, lname " +
  83. "FROM employee";
  84. dbcmd.CommandText = sql;
  85. IDataReader reader = dbcmd.ExecuteReader();
  86. while(reader.Read()) {
  87. string FirstName = (string) reader["fname"];
  88. string LastName = (string) reader["lname"];
  89. Console.WriteLine("Name: " +
  90. FirstName + " " + LastName);
  91. }
  92. // clean up
  93. reader.Close();
  94. reader = null;
  95. dbcmd.Dispose();
  96. dbcmd = null;
  97. dbcon.Close();
  98. dbcon = null;
  99. }
  100. }
  101. </pre>
  102. </li>
  103. <li>Building C# Example:
  104. <ul>
  105. <li>Save the example to a file, such as, TestExample.cs</li>
  106. <li>Build on Linux:
  107. <pre>
  108. mcs TestExample.cs -r System.Data.dll \
  109. -r Mono.Data.TdsClient.dll
  110. </pre>
  111. </li>
  112. <li>Build on Windows via Cygwin:
  113. <pre>
  114. mono C:/cygwin/home/MyHome/mono/install/bin/mcs.exe \
  115. TestExample.cs \
  116. -lib:C:/cygwin/home/MyHome/mono/install/lib \
  117. -r System.Data.dll -r Mono.Data.TdsClient.dll
  118. </pre>
  119. </li>
  120. </ul>
  121. </li>
  122. <li>Running the Example:
  123. <pre>
  124. mono TestExample.exe
  125. </pre>
  126. </li>
  127. </ul>