AccessDataSource.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. //
  2. // System.Web.UI.WebControls.AccessDataSource.cs
  3. //
  4. // Authors:
  5. // Sanjay Gupta ([email protected])
  6. //
  7. // (C) 2004 Novell, Inc (http://www.novell.com)
  8. //
  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. #if NET_2_0
  30. using System.IO;
  31. using System.ComponentModel;
  32. namespace System.Web.UI.WebControls {
  33. [ DesignerAttribute ("System.Web.UI.Design.WebControls.AccessDataSourceDesigner, System.Design",
  34. "System.ComponentModel.Design.IDesigner")]
  35. public class AccessDataSource : SqlDataSource
  36. {
  37. string dataFile;
  38. public AccessDataSource () : base ()
  39. {
  40. this.ProviderName = "System.Data.OleDb";
  41. }
  42. public AccessDataSource (string dataFile, string selectCommand) :
  43. base (String.Empty, selectCommand)
  44. {
  45. this.dataFile = dataFile;
  46. //After setting dataFile, connectionString gets recreated
  47. //On accessing ConnectionString, MS.Net throws NullReferenceException
  48. //Need to dig more on this.
  49. this.ProviderName = "System.Data.OleDb";
  50. }
  51. /*[MonoTODO]
  52. protected override SqlDataSourceView CreateDataSourceView (string view)
  53. {
  54. throw new NotImplementedException ();
  55. }
  56. [MonoTODO]
  57. protected internal override void SaveDataToCache (int startingRowIndex,
  58. int maxRows, object data)
  59. {
  60. throw new NotImplementedException ();
  61. }
  62. [MonoTODO]
  63. protected internal override void SaveTotalRowCountToCache(int totalRows)
  64. {
  65. throw new NotImplementedException ();
  66. }
  67. public override string SqlCacheDependency {
  68. get { throw new NotSupportedException ("AccessDataSource does not supports SQL Cache Dependencies."); }
  69. set { throw new NotSupportedException ("AccessDataSource does not supports SQL Cache Dependencies."); }
  70. }*/
  71. //Above commented out portion will come into place after implementing
  72. // stuff in SqlDataSource class.
  73. //Overrid implementation will depend on how .Net stores data in
  74. //Cache property of HttpContext object.
  75. [BrowsableAttribute (false),
  76. DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
  77. public override string ConnectionString {
  78. get { return this.ConnectionString; }
  79. set { throw new InvalidOperationException
  80. ("The ConnectionString is automatically generated for AccessDataSource and hence cannot be set.");
  81. }
  82. }
  83. [UrlPropertyAttribute (), DefaultValueAttribute (""),
  84. WebCategoryAttribute ("Data"),
  85. WebSysDescriptionAttribute ("MS Office Access database file name"),
  86. EditorAttribute ("System.Web.UI.Design.MdbDataFileEditor, System.Design",
  87. "System.Drawing.Design.UITypeEditor, System.Drawing")]
  88. public string DataFile {
  89. get { return dataFile; }
  90. set { dataFile = value; }
  91. //After setting dataFile, connectionString gets recreated
  92. //On accessing ConnectionString, MS.Net throws NullReferenceException
  93. //Need to dig more on this.
  94. }
  95. [BrowsableAttribute (false),
  96. DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
  97. public override string ProviderName {
  98. get { return this.ProviderName; }
  99. set { throw new InvalidOperationException
  100. ("Setting ProviderName on an AccessDataSource is not allowed");
  101. }
  102. }
  103. }
  104. }
  105. #endif