OdbcDataAdapter.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. //
  2. // System.Data.Odbc.OdbcDataAdapter.cs
  3. //
  4. // Author:
  5. // Rodrigo Moya ([email protected])
  6. // Daniel Morgan ([email protected])
  7. // Tim Coleman ([email protected])
  8. //
  9. // (C) Ximian, Inc 2002
  10. // Copyright (C) 2002 Tim Coleman
  11. //
  12. //
  13. // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
  14. //
  15. // Permission is hereby granted, free of charge, to any person obtaining
  16. // a copy of this software and associated documentation files (the
  17. // "Software"), to deal in the Software without restriction, including
  18. // without limitation the rights to use, copy, modify, merge, publish,
  19. // distribute, sublicense, and/or sell copies of the Software, and to
  20. // permit persons to whom the Software is furnished to do so, subject to
  21. // the following conditions:
  22. //
  23. // The above copyright notice and this permission notice shall be
  24. // included in all copies or substantial portions of the Software.
  25. //
  26. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  27. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  28. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  29. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  30. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  31. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  32. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  33. //
  34. using System;
  35. using System.ComponentModel;
  36. using System.Data;
  37. using System.Data.Common;
  38. namespace System.Data.Odbc
  39. {
  40. [DefaultEvent ("RowUpdated")]
  41. [DesignerAttribute ("Microsoft.VSDesigner.Data.VS.OdbcDataAdapterDesigner, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.ComponentModel.Design.IDesigner")]
  42. [ToolboxItemAttribute ("Microsoft.VSDesigner.Data.VS.OdbcDataAdapterToolboxItem, "+ Consts.AssemblyMicrosoft_VSDesigner)]
  43. public sealed class OdbcDataAdapter : DbDataAdapter, IDbDataAdapter, ICloneable
  44. {
  45. #region Fields
  46. OdbcCommand deleteCommand;
  47. OdbcCommand insertCommand;
  48. OdbcCommand selectCommand;
  49. OdbcCommand updateCommand;
  50. #endregion
  51. #region Constructors
  52. public OdbcDataAdapter () : this ((OdbcCommand) null)
  53. {
  54. }
  55. public OdbcDataAdapter (OdbcCommand selectCommand)
  56. {
  57. SelectCommand = selectCommand;
  58. }
  59. public OdbcDataAdapter (string selectCommandText, OdbcConnection selectConnection)
  60. : this (new OdbcCommand (selectCommandText, selectConnection))
  61. {
  62. }
  63. public OdbcDataAdapter (string selectCommandText, string selectConnectionString)
  64. : this (selectCommandText, new OdbcConnection (selectConnectionString))
  65. {
  66. }
  67. #endregion
  68. #region Properties
  69. [OdbcCategory ("Update")]
  70. [OdbcDescription ("Used during Update for deleted rows in DataSet.")]
  71. [DefaultValue (null)]
  72. [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing )]
  73. public new OdbcCommand DeleteCommand {
  74. get { return deleteCommand; }
  75. set { deleteCommand = value; }
  76. }
  77. [OdbcCategory ("Update")]
  78. [OdbcDescription ("Used during Update for new rows in DataSet.")]
  79. [DefaultValue (null)]
  80. [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing )]
  81. public new OdbcCommand InsertCommand {
  82. get { return insertCommand; }
  83. set { insertCommand = value; }
  84. }
  85. [OdbcCategory ("Fill")]
  86. [OdbcDescription ("Used during Fill/FillSchema.")]
  87. [DefaultValue (null)]
  88. [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing )]
  89. public new OdbcCommand SelectCommand {
  90. get { return selectCommand; }
  91. set { selectCommand = value; }
  92. }
  93. [OdbcCategory ("Update")]
  94. [OdbcDescription ("Used during Update for modified rows in DataSet.")]
  95. [DefaultValue (null)]
  96. [EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBCommandEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing )]
  97. public new OdbcCommand UpdateCommand {
  98. get { return updateCommand; }
  99. set { updateCommand = value; }
  100. }
  101. IDbCommand IDbDataAdapter.DeleteCommand {
  102. get { return DeleteCommand; }
  103. set { DeleteCommand = (OdbcCommand) value; }
  104. }
  105. IDbCommand IDbDataAdapter.InsertCommand {
  106. get { return InsertCommand; }
  107. set { InsertCommand = (OdbcCommand) value; }
  108. }
  109. IDbCommand IDbDataAdapter.SelectCommand {
  110. get { return SelectCommand; }
  111. set { SelectCommand = (OdbcCommand) value; }
  112. }
  113. IDbCommand IDbDataAdapter.UpdateCommand {
  114. get { return UpdateCommand; }
  115. set { UpdateCommand = (OdbcCommand) value; }
  116. }
  117. #endregion // Properties
  118. #region Methods
  119. protected override RowUpdatedEventArgs CreateRowUpdatedEvent (DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
  120. {
  121. return new OdbcRowUpdatedEventArgs (dataRow, command, statementType, tableMapping);
  122. }
  123. protected override RowUpdatingEventArgs CreateRowUpdatingEvent (DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
  124. {
  125. return new OdbcRowUpdatingEventArgs (dataRow, command, statementType, tableMapping);
  126. }
  127. protected override void OnRowUpdated (RowUpdatedEventArgs value)
  128. {
  129. if (RowUpdated != null)
  130. RowUpdated (this, (OdbcRowUpdatedEventArgs) value);
  131. }
  132. protected override void OnRowUpdating (RowUpdatingEventArgs value)
  133. {
  134. if (RowUpdating != null)
  135. RowUpdating (this, (OdbcRowUpdatingEventArgs) value);
  136. }
  137. [MonoTODO]
  138. object ICloneable.Clone ()
  139. {
  140. throw new NotImplementedException ();
  141. }
  142. #endregion // Methods
  143. #region Events and Delegates
  144. public event OdbcRowUpdatedEventHandler RowUpdated;
  145. public event OdbcRowUpdatingEventHandler RowUpdating;
  146. #endregion // Events and Delegates
  147. }
  148. }