sqlclient 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. * Microsoft SQL Server Provider
  2. <ul>
  3. <li>ADO.NET Provider for Microsoft SQL Server 7/2000 databases</li>
  4. <li>Exists in namespace System.Data.SqlClient and assembly System.Data</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.TdsClient and Mono.Data.SybaseClient 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 7.0</li>
  12. <li>Does not support trusted connections</li>
  13. </ul>
  14. ** Current Status
  15. <ul>
  16. <li>Able to connect to Microsoft SQL Server 7/2000 databases</li>
  17. <li>Connection pooling works.</li>
  18. <li>Stored Procedures work</li>
  19. <li>Parameters work.</li>
  20. <li>Prepare works.</li>
  21. <li>SQL commands can be executed
  22. via ExecuteNonQuery() of a SqlCommand.</li>
  23. <li>SQL aggregates can be executed and a single row and single column
  24. result can be retrieved via ExecuteScalar() of a SqlCommand</li>
  25. <li>SQL queries can be executed via ExecuteReader() and results
  26. can be retrieved via SqlDataReader.</li>
  27. <li>a DataTable with schema info about a result can be gotten via GetSchemaTable()
  28. in a SqlDataReader</li>
  29. <li>XML can be read via ExecuteXmlReader in a SqlCommand.</li>
  30. <li>Data can be filled in a DataTable in a DataSet via a SqlDataAdapter</li>
  31. <li>Uses TDS Protocol Version 7.0</li>
  32. <li><a href="http://www.go-mono.com/tds-providers.html">Design of the Microsoft SQL Server, Sybase, and TDS Providers in Mono</a></li>
  33. </ul>
  34. ** Action plan
  35. <ul>
  36. <li>Connection timeouts is being developed now.
  37. <li>Needs more testing...
  38. </ul>
  39. ** Testing
  40. <ul>
  41. <li>Have a working mono and mcs installed</li>
  42. <li>Have access to a Microsoft SQL Server database
  43. or either download it:
  44. <ul>
  45. <li><a href="http://www.microsoft.com/sql/default.asp">Microsoft SQL Server</a></li>
  46. </ul>
  47. </li>
  48. <li>Located at mcs/class/System.Data/Test is a test for System.Data.SqlClient
  49. named SqlTest.cs and you could use this as a basis for your test.</li>
  50. <li>C# Example:
  51. <pre>
  52. using System;
  53. using System.Data;
  54. using System.Data.SqlClient;
  55. public class Test
  56. {
  57. public static void Main(string[] args)
  58. {
  59. string connectionString =
  60. "Server=localhost;" +
  61. "Database=pubs;" +
  62. "User ID=sa;" +
  63. "Password=;";
  64. IDbConnection dbcon;
  65. dbcon = new SqlConnection(connectionString);
  66. IDbCommand dbcmd = dbcon.CreateCommand();
  67. string sql =
  68. "SELECT fname, lname " +
  69. "FROM employee";
  70. dbcmd.ConnectionString = sql;
  71. IDataReader reader = dbcmd.ExecuteReader();
  72. while(reader.Read()) {
  73. string FirstName = reader["fname"];
  74. string LastName = reader["lname"];
  75. Console.WriteLine("Name: " +
  76. FirstName + " " + LastName);
  77. }
  78. // clean up
  79. reader.Close();
  80. reader = null;
  81. dbcmd.Dispose();
  82. dbcmd = null;
  83. dbcon.Close();
  84. dbcon = null;
  85. }
  86. }
  87. </pre>
  88. </li>
  89. <li>Building C# Example:
  90. <ul>
  91. <li>Save the example to a file, such as, TestExample.cs</li>
  92. <li>Build on Linux:
  93. <pre>
  94. mcs TestExample.cs -r System.Data.dll
  95. </pre>
  96. </li>
  97. <li>Build on Windows via Cygwin:
  98. <pre>
  99. mono C:/cygwin/home/MyHome/mono/install/bin/mcs.exe \
  100. TestExample.cs -r System.Data.dll
  101. </pre>
  102. </li>
  103. </ul>
  104. </li>
  105. <li>Running the Example:
  106. <pre>
  107. mono TestExample.exe
  108. </pre>
  109. </li>
  110. </ul>