blob: 596dc8ee4108315f7de1b570f522db381fe1f42e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
|
//
// System.Web.UI.WebControls.SqlDataSource
//
// Authors:
// Ben Maurer (bmaurer@users.sourceforge.net)
//
// (C) 2003 Ben Maurer
//
#if NET_2_0
using System.Collections;
using System.Collections.Specialized;
using System.Text;
namespace System.Web.UI.WebControls {
public class SqlDataSource : DataSourceControl {
public SqlDataSource ()
{
}
public SqlDataSource (string connectionString, string selectCommand)
{
ConnectionString = connectionString;
SelectCommand = selectCommand;
}
public SqlDataSource (string providerName, string connectionString, string selectCommand)
{
ProviderName = providerName;
ConnectionString = connectionString;
SelectCommand = selectCommand;
}
protected override DataSourceView GetView (string viewName)
{
if (viewName == "" || viewName == null)
return View;
else
throw new ArgumentException ("viewName");
}
protected override ICollection GetViewNames ()
{
return new string [] { "DefaultView" };
}
public int Insert ()
{
return View.Insert ();
}
public int Delete ()
{
return View.Delete ();
}
public IEnumerable Select ()
{
return View.Select ();
}
public int Update ()
{
return View.Update ();
}
protected override void LoadViewState (object savedState)
{
Pair p = savedState as Pair;
if (p != null) {
base.LoadViewState (p.First);
((IStateManager) View).LoadViewState (p.Second);
}
}
protected override object SaveViewState ()
{
object me = base.SaveViewState (), view = ((IStateManager) View).SaveViewState ();
if (me != null || view != null)
return new Pair (me, view);
else
return null;
}
protected override void TrackViewState ()
{
base.TrackViewState ();
((IStateManager) View).TrackViewState ();
}
//protected virtual DataSourceCache Cache { get; }
//public virtual int CacheDuration { get; set; }
//public virtual DataSourceCacheExpiry CacheExpirationPolicy { get; set; }
//public virtual string CacheKeyDependency { get; set; }
//public virtual string SqlCacheDependency { get; set; }
//public virtual bool EnableCaching { get; set; }
public virtual string ProviderName {
get {
string val = ViewState ["ProviderName"] as string;
return val == null ? "System.Data.SqlClient" : val;
}
set { ViewState ["ProviderName"] = value; }
}
public virtual string ConnectionString {
get {
string val = ViewState ["ConnectionString"] as string;
return val == null ? "" : val;
}
set { ViewState ["ConnectionString"] = value; }
}
public SqlDataSourceMode DataSourceMode {
get {
object val = ViewState ["DataSourceMode"];
return val == null ? SqlDataSourceMode.DataSet : (SqlDataSourceMode) val;
}
set { ViewState ["DataSourceMode"] = value; }
}
public string DeleteCommand {
get { return View.DeleteCommand; }
set { View.DeleteCommand = value; }
}
public ParameterCollection DeleteParameters {
get { return View.DeleteParameters; }
}
public ParameterCollection FilterParameters {
get { return View.FilterParameters; }
}
public string InsertCommand {
get { return View.InsertCommand; }
set { View.InsertCommand = value; }
}
public ParameterCollection InsertParameters {
get { return View.InsertParameters; }
}
public string SelectCommand {
get { return View.SelectCommand; }
set { View.SelectCommand = value; }
}
public ParameterCollection SelectParameters {
get { return View.SelectParameters; }
}
public string UpdateCommand {
get { return View.UpdateCommand; }
set { View.UpdateCommand = value; }
}
public ParameterCollection UpdateParameters {
get { return View.UpdateParameters; }
}
public string FilterExpression {
get { return View.FilterExpression; }
set { View.FilterExpression = value; }
}
public event SqlDataSourceStatusEventHandler Deleted {
add { View.Deleted += value; }
remove { View.Deleted -= value; }
}
public event SqlDataSourceCommandEventHandler Deleting {
add { View.Deleting += value; }
remove { View.Deleting -= value; }
}
public event SqlDataSourceStatusEventHandler Inserted {
add { View.Inserted += value; }
remove { View.Inserted -= value; }
}
public event SqlDataSourceCommandEventHandler Inserting {
add { View.Inserting += value; }
remove { View.Inserting -= value; }
}
public event SqlDataSourceStatusEventHandler Selected {
add { View.Selected += value; }
remove { View.Selected -= value; }
}
public event SqlDataSourceCommandEventHandler Selecting {
add { View.Selecting += value; }
remove { View.Selecting -= value; }
}
public event SqlDataSourceStatusEventHandler Updated {
add { View.Updated += value; }
remove { View.Updated -= value; }
}
public event SqlDataSourceCommandEventHandler Updating {
add { View.Updating += value; }
remove { View.Updating -= value; }
}
SqlDataSourceView view;
SqlDataSourceView View {
get {
if (view == null) {
view = new SqlDataSourceView (this, "DefaultView");
view.DataSourceViewChanged += new EventHandler (ViewChanged);
if (IsTrackingViewState)
((IStateManager) view).TrackViewState ();
}
return view;
}
}
void ViewChanged (object source, EventArgs e)
{
OnDataSourceChanged (e);
}
}
}
#endif
|