1 //
2 // System.Web.UI.WebControls.AccessDataSourceView
3 //
4 // Authors:
5 //	Sanjay Gupta (gsanjay@novell.com)
6 //
7 // (C) Novell, Inc. (http://www.novell.com)
8 //
9 
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 //
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 //
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30 
31 using System.Collections;
32 using System.Collections.Specialized;
33 using System.Text;
34 using System.Data;
35 using System.ComponentModel;
36 using System.Data.OleDb;
37 using System.Security.Permissions;
38 
39 namespace System.Web.UI.WebControls
40 {
41 	[AspNetHostingPermissionAttribute (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
42 	public class AccessDataSourceView : SqlDataSourceView
43 	{
44 		OleDbConnection oleConnection;
45 		OleDbCommand oleCommand;
46 		AccessDataSource dataSource;
AccessDataSourceView(AccessDataSource owner, string name, HttpContext context)47 		public AccessDataSourceView (AccessDataSource owner, string name, HttpContext context)
48 			: base (owner, name, context)
49 		{
50 			dataSource = owner;
51 			oleConnection = new OleDbConnection (owner.ConnectionString);
52 		}
53 
54 		[MonoTODO ("Handle arguments")]
ExecuteSelect( DataSourceSelectArguments arguments)55 		protected internal override IEnumerable ExecuteSelect (
56 						DataSourceSelectArguments arguments)
57 		{
58 			oleCommand = new OleDbCommand (this.SelectCommand, oleConnection);
59 			SqlDataSourceSelectingEventArgs cmdEventArgs = new SqlDataSourceSelectingEventArgs (oleCommand, arguments);
60 			OnSelecting (cmdEventArgs);
61 			IEnumerable enums = null;
62 			Exception exception = null;
63 			OleDbDataReader reader = null;
64 			try {
65 				System.IO.File.OpenRead (dataSource.DataFile).Close ();
66 				oleConnection.Open ();
67 				reader = (OleDbDataReader)oleCommand.ExecuteReader ();
68 
69 				//enums = reader.GetEnumerator ();
70 				throw new NotImplementedException("OleDbDataReader doesnt implements GetEnumerator method yet");
71 			} catch (Exception e) {
72 				exception = e;
73 			}
74 			SqlDataSourceStatusEventArgs statusEventArgs =
75 				new SqlDataSourceStatusEventArgs (oleCommand, reader.RecordsAffected, exception);
76 			OnSelected (statusEventArgs);
77 			if (exception !=null)
78 				throw exception;
79 			return enums;
80 		}
81 	}
82 }
83 
84