OleDbCommandBuilder.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. //
  2. // System.Data.OleDb.OleDbCommandBuilder
  3. //
  4. // Author:
  5. // Rodrigo Moya ([email protected])
  6. // Tim Coleman ([email protected])
  7. //
  8. // Copyright (C) Rodrigo Moya, 2002
  9. // Copyright (C) Tim Coleman, 2002
  10. //
  11. //
  12. // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
  13. //
  14. // Permission is hereby granted, free of charge, to any person obtaining
  15. // a copy of this software and associated documentation files (the
  16. // "Software"), to deal in the Software without restriction, including
  17. // without limitation the rights to use, copy, modify, merge, publish,
  18. // distribute, sublicense, and/or sell copies of the Software, and to
  19. // permit persons to whom the Software is furnished to do so, subject to
  20. // the following conditions:
  21. //
  22. // The above copyright notice and this permission notice shall be
  23. // included in all copies or substantial portions of the Software.
  24. //
  25. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  26. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  27. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  28. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  29. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  30. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  31. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  32. //
  33. using System.ComponentModel;
  34. using System.Data;
  35. using System.Data.Common;
  36. namespace System.Data.OleDb
  37. {
  38. /// <summary>
  39. /// Provides a means of automatically generating single-table commands used to reconcile changes made to a DataSet with the associated database. This class cannot be inherited.
  40. /// </summary>
  41. public sealed class OleDbCommandBuilder :
  42. DbCommandBuilder
  43. {
  44. #region Fields
  45. OleDbDataAdapter adapter;
  46. #endregion // Fields
  47. #region Constructors
  48. public OleDbCommandBuilder ()
  49. {
  50. }
  51. public OleDbCommandBuilder (OleDbDataAdapter adapter)
  52. : this ()
  53. {
  54. this.adapter = adapter;
  55. }
  56. #endregion // Constructors
  57. #region Properties
  58. [DefaultValue (null)]
  59. public new OleDbDataAdapter DataAdapter {
  60. get {
  61. return adapter;
  62. }
  63. set {
  64. adapter = value;
  65. }
  66. }
  67. #endregion // Properties
  68. #region Methods
  69. protected override void ApplyParameterInfo (DbParameter parameter,
  70. DataRow datarow,
  71. StatementType statementType,
  72. bool whereClause)
  73. {
  74. OleDbParameter p = (OleDbParameter) parameter;
  75. p.Size = int.Parse (datarow ["ColumnSize"].ToString ());
  76. if (datarow ["NumericPrecision"] != DBNull.Value) {
  77. p.Precision = byte.Parse (datarow ["NumericPrecision"].ToString ());
  78. }
  79. if (datarow ["NumericScale"] != DBNull.Value) {
  80. p.Scale = byte.Parse (datarow ["NumericScale"].ToString ());
  81. }
  82. p.DbType = (DbType) datarow ["ProviderType"];
  83. }
  84. [MonoTODO]
  85. public static void DeriveParameters (OleDbCommand command)
  86. {
  87. if (command.CommandType != CommandType.StoredProcedure) {
  88. throw new InvalidOperationException ("You can perform this " +
  89. "operation only on CommandTye" +
  90. " StoredProcedure");
  91. }
  92. // FIXME: Retrive info from server
  93. throw new NotImplementedException ();
  94. }
  95. [MonoTODO]
  96. public new OleDbCommand GetDeleteCommand ()
  97. {
  98. throw new NotImplementedException ();
  99. }
  100. [MonoTODO]
  101. public new OleDbCommand GetDeleteCommand (bool useColumnsForParameterNames)
  102. {
  103. throw new NotImplementedException ();
  104. }
  105. [MonoTODO]
  106. public new OleDbCommand GetInsertCommand ()
  107. {
  108. throw new NotImplementedException ();
  109. }
  110. [MonoTODO]
  111. public new OleDbCommand GetInsertCommand (bool useColumnsForParameterNames)
  112. {
  113. throw new NotImplementedException ();
  114. }
  115. protected override string GetParameterName (int parameterOrdinal)
  116. {
  117. return String.Format("@p{0}", parameterOrdinal);
  118. }
  119. protected override string GetParameterName (string parameterName)
  120. {
  121. return String.Format("@{0}", parameterName);
  122. }
  123. protected override string GetParameterPlaceholder (int parameterOrdinal)
  124. {
  125. return GetParameterName (parameterOrdinal);
  126. }
  127. [MonoTODO]
  128. public new OleDbCommand GetUpdateCommand ()
  129. {
  130. throw new NotImplementedException ();
  131. }
  132. [MonoTODO]
  133. public new OleDbCommand GetUpdateCommand (bool useColumnsForParameterNames)
  134. {
  135. throw new NotImplementedException ();
  136. }
  137. [MonoTODO]
  138. public override string QuoteIdentifier(string unquotedIdentifier)
  139. {
  140. return base.QuoteIdentifier (unquotedIdentifier);
  141. }
  142. [MonoTODO]
  143. public string QuoteIdentifier(string unquotedIdentifier, OleDbConnection connection)
  144. {
  145. throw new NotImplementedException ();
  146. }
  147. [MonoTODO]
  148. protected override void SetRowUpdatingHandler(DbDataAdapter adapter)
  149. {
  150. throw new NotImplementedException ();
  151. }
  152. [MonoTODO]
  153. public override string UnquoteIdentifier(string quotedIdentifier)
  154. {
  155. return base.UnquoteIdentifier (quotedIdentifier);
  156. }
  157. [MonoTODO]
  158. public string UnquoteIdentifier(string quotedIdentifier, OleDbConnection connection)
  159. {
  160. throw new NotImplementedException ();
  161. }
  162. #endregion // Methods
  163. }
  164. }