OdbcDataReaderTest.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. //
  2. // OdbcDataReaderTest.cs
  3. //
  4. // Author:
  5. // Satya Sudha K ([email protected])
  6. //
  7. //
  8. // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
  9. //
  10. // Permission is hereby granted, free of charge, to any person obtaining
  11. // a copy of this software and associated documentation files (the
  12. // "Software"), to deal in the Software without restriction, including
  13. // without limitation the rights to use, copy, modify, merge, publish,
  14. // distribute, sublicense, and/or sell copies of the Software, and to
  15. // permit persons to whom the Software is furnished to do so, subject to
  16. // the following conditions:
  17. //
  18. // The above copyright notice and this permission notice shall be
  19. // included in all copies or substantial portions of the Software.
  20. //
  21. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  22. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  24. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  25. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  26. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  27. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  28. //
  29. using System;
  30. using System.Data;
  31. using System.Data.Odbc;
  32. namespace MonoTests.System.Data {
  33. public class MySqlOdbcRetrieve : MySqlRetrieve {
  34. public MySqlOdbcRetrieve (string database) : base (database)
  35. {
  36. }
  37. // returns a Open connection
  38. public override void GetConnection ()
  39. {
  40. string connectionString = null;
  41. try {
  42. connectionString = ConfigClass.GetElement (configDoc, "database", "OdbcConnString");
  43. } catch (Exception e) {
  44. Console.WriteLine ("Error reading the config file");
  45. Console.WriteLine (e.Message);
  46. return;
  47. }
  48. con = new OdbcConnection (connectionString);
  49. try {
  50. con.Open ();
  51. } catch (Exception e) {
  52. Console.WriteLine ("Cannot establish connection with the database");
  53. con = null;
  54. }
  55. }
  56. }
  57. public class MsSqlOdbcRetrieve : MsSqlRetrieve {
  58. public MsSqlOdbcRetrieve (string database) : base (database)
  59. {
  60. }
  61. // returns a Open connection
  62. public override void GetConnection ()
  63. {
  64. string connectionString = null;
  65. try {
  66. connectionString = ConfigClass.GetElement (configDoc, "database", "OdbcConnString");
  67. } catch (Exception e) {
  68. Console.WriteLine ("Error reading the config file");
  69. Console.WriteLine (e.Message);
  70. return;
  71. }
  72. con = new OdbcConnection (connectionString);
  73. try {
  74. con.Open ();
  75. } catch (Exception e) {
  76. Console.WriteLine ("Cannot establish connection with the database");
  77. con = null;
  78. }
  79. }
  80. }
  81. public class OracleOdbcRetrieve : OraRetrieve {
  82. public OracleOdbcRetrieve (string database) : base (database)
  83. {
  84. }
  85. // returns a Open connection
  86. public override void GetConnection ()
  87. {
  88. string connectionString = null;
  89. try {
  90. connectionString = ConfigClass.GetElement (configDoc, "database", "OdbcConnString");
  91. } catch (Exception e) {
  92. Console.WriteLine ("Error reading the config file");
  93. Console.WriteLine (e.Message);
  94. return;
  95. }
  96. con = new OdbcConnection (connectionString);
  97. try {
  98. con.Open ();
  99. } catch (Exception e) {
  100. Console.WriteLine ("Cannot establish connection with the database");
  101. con = null;
  102. }
  103. }
  104. }
  105. public class PostgreOdbcRetrieve : MySqlRetrieve {
  106. public PostgreOdbcRetrieve (string database) : base (database)
  107. {
  108. }
  109. // returns a Open connection
  110. public override void GetConnection ()
  111. {
  112. string connectionString = null;
  113. try {
  114. connectionString = ConfigClass.GetElement (configDoc, "database", "OdbcConnString");
  115. } catch (Exception e) {
  116. Console.WriteLine ("Error reading the config file");
  117. Console.WriteLine (e.Message);
  118. return;
  119. }
  120. con = new OdbcConnection (connectionString);
  121. try {
  122. con.Open ();
  123. } catch (Exception e) {
  124. Console.WriteLine ("Cannot establish connection with the database");
  125. con = null;
  126. }
  127. }
  128. }
  129. }