aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MSSQL/AutoClosingSqlCommand.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Data/MSSQL/AutoClosingSqlCommand.cs')
-rw-r--r--OpenSim/Data/MSSQL/AutoClosingSqlCommand.cs219
1 files changed, 0 insertions, 219 deletions
diff --git a/OpenSim/Data/MSSQL/AutoClosingSqlCommand.cs b/OpenSim/Data/MSSQL/AutoClosingSqlCommand.cs
deleted file mode 100644
index 93e48cd..0000000
--- a/OpenSim/Data/MSSQL/AutoClosingSqlCommand.cs
+++ /dev/null
@@ -1,219 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System.Data;
29using System.Data.SqlClient;
30
31namespace OpenSim.Data.MSSQL
32{
33 /// <summary>
34 /// Encapsulates a SqlCommand object but ensures that when it is disposed, its connection is closed and disposed also.
35 /// </summary>
36 internal class AutoClosingSqlCommand : IDbCommand
37 {
38 private SqlCommand realCommand;
39
40 public AutoClosingSqlCommand(SqlCommand cmd)
41 {
42 realCommand = cmd;
43 }
44
45 #region IDbCommand Members
46
47 public void Cancel()
48 {
49 realCommand.Cancel();
50 }
51
52 public string CommandText
53 {
54 get
55 {
56 return realCommand.CommandText;
57 }
58 set
59 {
60 realCommand.CommandText = value;
61 }
62 }
63
64 public int CommandTimeout
65 {
66 get
67 {
68 return realCommand.CommandTimeout;
69 }
70 set
71 {
72 realCommand.CommandTimeout = value;
73 }
74 }
75
76 public CommandType CommandType
77 {
78 get
79 {
80 return realCommand.CommandType;
81 }
82 set
83 {
84 realCommand.CommandType = value;
85 }
86 }
87
88 IDbConnection IDbCommand.Connection
89 {
90 get
91 {
92 return realCommand.Connection;
93 }
94 set
95 {
96 realCommand.Connection = (SqlConnection) value;
97 }
98 }
99
100 public SqlConnection Connection
101 {
102 get
103 {
104 return realCommand.Connection;
105 }
106 }
107
108 IDbDataParameter IDbCommand.CreateParameter()
109 {
110 return realCommand.CreateParameter();
111 }
112
113 public SqlParameter CreateParameter()
114 {
115 return realCommand.CreateParameter();
116 }
117
118 public int ExecuteNonQuery()
119 {
120 return realCommand.ExecuteNonQuery();
121 }
122
123 IDataReader IDbCommand.ExecuteReader(CommandBehavior behavior)
124 {
125 return realCommand.ExecuteReader(behavior);
126 }
127
128 public SqlDataReader ExecuteReader(CommandBehavior behavior)
129 {
130 return realCommand.ExecuteReader(behavior);
131 }
132
133 IDataReader IDbCommand.ExecuteReader()
134 {
135 return realCommand.ExecuteReader();
136 }
137
138 public SqlDataReader ExecuteReader()
139 {
140 return realCommand.ExecuteReader();
141 }
142
143 public object ExecuteScalar()
144 {
145 return realCommand.ExecuteScalar();
146 }
147
148 IDataParameterCollection IDbCommand.Parameters
149 {
150 get { return realCommand.Parameters; }
151 }
152
153 public SqlParameterCollection Parameters
154 {
155 get { return realCommand.Parameters; }
156 }
157
158 public void Prepare()
159 {
160 realCommand.Prepare();
161 }
162
163// IDbTransaction IDbCommand.Transaction
164// {
165// get
166// {
167// return realCommand.Transaction;
168// }
169// set
170// {
171// realCommand.Transaction = (SqlTransaction) value;
172// }
173// }
174
175 public IDbTransaction Transaction
176 {
177 get { return realCommand.Transaction; }
178 set { realCommand.Transaction = (SqlTransaction)value; }
179 }
180
181 UpdateRowSource IDbCommand.UpdatedRowSource
182 {
183 get
184 {
185 return realCommand.UpdatedRowSource;
186 }
187 set
188 {
189 realCommand.UpdatedRowSource = value;
190 }
191 }
192
193 #endregion
194
195 #region IDisposable Members
196
197 public void Dispose()
198 {
199 SqlConnection conn = realCommand.Connection;
200 try
201 {
202 realCommand.Dispose();
203 }
204 finally
205 {
206 try
207 {
208 conn.Close();
209 }
210 finally
211 {
212 conn.Dispose();
213 }
214 }
215 }
216
217 #endregion
218 }
219}