按分工来说,这部分只起把数据从数据库中读取出来,到底用ORM还是用什么传输数据,那是另外一回事情了,
这部分的功能,从分层的角度来讲,只是数据库访问层的一个实用工具而已。
我们大家都希望自己的程序能健壮一些,写一遍后到处都能运行,当然没有太理想的完美万能的通用数据库访问方法吧,
就算有万能的,我还没见到过,嘿嘿。
以前我用
OleDb方式访问数据库,这样 Oracle和SqlServer上的写法大致是一致的,将程序移植到另一个数据库系统上
修改的量比较少,但是总感觉不是很爽,有时候希望用Oracle的数据库联接方式、有时候希望是SqlServer的数据库连接。
而且以前有些程序就写成了Oracle连接上,还要把这些程序都移植到新系统里来,总不能让别人翻天覆地的把程序都修改
了,我是没问题,但是别人不同意啊,当然还有性能上的问题等等。
IDbHelper 接口,里面定义了,经常用的数据库调用方法。
1.
获得数据库日期时间
2.
检查参数的安全性
3. Sql参数处理
4. 常用的数据库命令
5. 事务控制
6. 异步调用数据库
欢迎大家提出宝贵的改进意见
1//------------------------------------------------------------
2// All Rights Reserved , Copyright (C) 2008 , Jirisoft , Ltd.
3//------------------------------------------------------------
4
5using System;
6using System.Data;
7using System.Data.Common;
8
9namespace Jirisoft.Common.DbUtilities
10{
11 using Jirisoft.Common;
12
13 /**//// <summary>
14 /// IBaseDbConnection
15 /// 数据库访问通用类标准接口。
16 ///
17 /// 修改纪录
18 ///
19 /// 2008.06.03 版本:1.2 JiRiGaLa 增加 DbParameter[] myDbParameters 方法。
20 /// 2008.05.07 版本:1.1 JiRiGaLa 增加GetWhereString定义。
21 /// 2008.03.20 版本:1.0 JiRiGaLa 创建标准接口,这次应该算是一次飞跃。
22 ///
23 /// 版本:1.1
24 ///
25 /// <author>
26 /// <name>JiRiGaLa</name>
27 /// <date>2008.03.20</date>
28 /// </author>
29 /// </summary>
30 public interface IDbHelper
31 {
32 String GetDBNow()#region String GetDBNow()
33 /**//// <summary>
34 /// 获得数据库日期时间
35 /// </summary>
36 /// <returns>日期时间</returns>
37 String GetDBNow();
38 #endregion
39
40 DateTime GetDBDateTime()#region DateTime GetDBDateTime()
41 /**//// <summary>
42 /// 获得数据库日期时间
43 /// </summary>
44 /// <returns>日期时间</returns>
45 DateTime GetDBDateTime();
46 #endregion
47
48 bool InTransaction#region bool InTransaction
49 /**//// <summary>
50 /// 是否已采用接口
51 /// </summary>
52 /// <returns></returns>
53 bool InTransaction
54 {
55 get;
56 set;
57 }
58 #endregion
59
60 IDbConnection GetDbConnection()#region IDbConnection GetDbConnection()
61 /**//// <summary>
62 /// 获取数据库连接
63 /// </summary>
64 /// <returns>数据库连接</returns>
65 IDbConnection GetDbConnection();
66 #endregion
67
68 IDbTransaction GetDbTransaction()#region IDbTransaction GetDbTransaction()
69 /**//// <summary>
70 /// 获取数据源上执行的事务
71 /// </summary>
72 /// <returns>数据源上执行的事务</returns>
73 IDbTransaction GetDbTransaction();
74 #endregion
75
76 IDbCommand GetDbCommand()#region IDbCommand GetDbCommand()
77 /**//// <summary>
78 /// 获取数据源上命令
79 /// </summary>
80 /// <returns>数据源上命令</returns>
81 IDbCommand GetDbCommand();
82 #endregion
83
84
85 IDbConnection Open()#region IDbConnection Open()
86 /**//// <summary>
87 /// 这时主要的获取数据库连接的方法
88 /// </summary>
89 /// <returns>数据库连接</returns>
90 IDbConnection Open();
91 #endregion
92
93 IDbConnection Open(String connectionString)#region IDbConnection Open(String connectionString)
94 /**//// <summary>
95 /// 获得新的数据库连接
96 /// </summary>
97 /// <param name="connectionString">数据库连接字符串</param>
98 /// <returns>数据库连接</returns>
99 IDbConnection Open(String connectionString);
100 #endregion
101
102 bool TestConn(String dataBaseType, String dataBase, String userName, String password, String workstation, bool trustLink)#region bool TestConn(String dataBaseType, String dataBase, String userName, String password, String workstation, bool trustLink)
103 /**//// <summary>
104 /// 测试数据库连接是否成功,这里抛出异常进行加强,充分使用系统的异常功能。
105 /// </summary>
106 /// <param name="dataBaseType">数据库类别</param>
107 /// <param name="dataBase">数据库名称</param>
108 /// <param name="userName">用户名</param>
109 /// <param name="password">密码</param>
110 /// <param name="workstation">服务器名称</param>
111 /// <param name="trustLink">是否信任的连接</param>
112 /// <returns>是否连接成功</returns>
113 bool TestConn(DataBaseType dataBaseType, String dataBase, String userName, String password, String workstation, bool trustLink);
114 #endregion
115
116 String SqlSafe(String value)#region String SqlSafe(String value)
117 /**//// <summary>
118 /// 检查参数的安全性
119 /// </summary>
120 /// <param name="value">参数</param>
121 /// <returns>安全的参数</returns>
122 String SqlSafe(String value);
123 #endregion
124
125 DbParameter GetParameter(String targetFiled, Object targetValue)#region DbParameter GetParameter(String targetFiled, Object targetValue)
126 /**//// <summary>
127 /// 获取参数
128 /// </summary>
129 /// <param name="targetFiled">目标字段</param>
130 /// <param name="targetValue">值</param>
131 /// <returns>参数</returns>
132 DbParameter GetParameter(String targetFiled, Object myTargetValue);
133 #endregion
134
135 DbParameter[] GetParameters(String[] targetFileds, Object[] targetValues)#region DbParameter[] GetParameters(String[] targetFileds, Object[] targetValues)
136 /**//// <summary>
137 /// 获取参数
138 /// </summary>
139 /// <param name="targetFiled">目标字段</param>
140 /// <param name="targetValue">值</param>
141 /// <returns>参数集</returns>
142 DbParameter[] GetParameters(String[] targetFileds, Object[] myTargetValues);
143 #endregion
144
145 void AddParameter(IDbCommand myTargetDbCommand, String targetFiled, Object targetValue)#region void AddParameter(IDbCommand myTargetDbCommand, String targetFiled, Object targetValue)
146 /**//// <summary>
147 /// 添加参数
148 /// </summary>
149 /// <param name="myTargetDbCommand">数据库命令</param>
150 /// <param name="targetFiled">目标字段</param>
151 /// <param name="targetValue">值</param>
152 void AddParameter(IDbCommand myTargetDbCommand, String targetFiled, Object myTargetValue);
153 #endregion
154
155 String GetWhereString(String[] names, ref Object[] values, String relation)#region String GetWhereString(String[] names, ref Object[] values, String relation)
156 /**//// <summary>
157 /// 获得条件语句
158 /// </summary>
159 /// <param name="names">字段名</param>
160 /// <param name="values">字段值</param>
161 /// <param name="relation">逻辑关系</param>
162 /// <returns>字符串</returns>
163 String GetWhereString(String[] names, ref Object[] values, String relation);
164 #endregion
165
166 String GetParameter(String parameter)#region String GetParameter(String parameter)
167 /**//// <summary>
168 /// 获得参数Sql表达式
169 /// </summary>
170 /// <param name="parameter">参数名称</param>
171 /// <returns>字符串</returns>
172 String GetParameter(String parameter);
173 #endregion
174
175 String PlusSign()#region String PlusSign()
176 /**//// <summary>
177 /// 字符串相加符号
178 /// </summary>
179 /// <returns>字符加</returns>
180 String PlusSign();
181 #endregion
182
183
184 IDataReader ExecuteReader(String sqlQuery)#region IDataReader ExecuteReader(String sqlQuery)
185 /**//// <summary>
186 /// 执行查询
187 /// </summary>
188 /// <param name="sqlQuery">sql查询</param>
189 /// <returns>结果集流</returns>
190 IDataReader ExecuteReader(String sqlQuery);
191 #endregion
192
193 IDataReader ExecuteReader(String sqlQuery, DbParameter[] myDbParameters);#region IDataReader ExecuteReader(String sqlQuery, DbParameter[] myDbParameters);
194 /**//// <summary>
195 /// 执行查询
196 /// </summary>
197 /// <param name="sqlQuery">sql查询</param>
198 /// <param name="myDbParameterCollection">参数集</param>
199 /// <returns>结果集流</returns>
200 IDataReader ExecuteReader(String sqlQuery, DbParameter[] myDbParameters);
201 #endregion
202
203 IDataReader ExecuteReader(String sqlQuery, String name, Object value)#region IDataReader ExecuteReader(String sqlQuery, String name, Object value)
204 /**//// <summary>
205 /// 执行查询
206 /// </summary>
207 /// <param name="sqlQuery">sql查询</param>
208 /// <param name="name">参数名</param>
209 /// <param name="value">参数值</param>
210 /// <returns>结果集流</returns>
211 IDataReader ExecuteReader(String sqlQuery, String name, Object value);
212 #endregion
213
214 IDataReader ExecuteReader(String sqlQuery, String[] names, Object[] values)#region IDataReader ExecuteReader(String sqlQuery, String[] names, Object[] values)
215 /**//// <summary>
216 /// 执行查询
217 /// </summary>
218 /// <param name="sqlQuery">sql查询</param>
219 /// <param name="names">参数名</param>
220 /// <param name="values">参数值</param>
221 /// <returns>结果集流</returns>
222 IDataReader ExecuteReader(String sqlQuery, String[] names, Object[] values);
223 #endregion
224
225 IDataReader ExecuteReader(CommandType myCommandType, String sqlQuery, DbParameter[] myDbParameters)#region IDataReader ExecuteReader(CommandType myCommandType, String sqlQuery, DbParameter[] myDbParameters)
226 /**//// <summary>
227 /// 执行查询
228 /// </summary>
229 /// <param name="myCommandType">命令分类</param>
230 /// <param name="sqlQuery">sql查询</param>
231 /// <param name="myDbParameterCollection">参数集</param>
232 /// <returns>结果集流</returns>
233 IDataReader ExecuteReader(CommandType myCommandType, String sqlQuery, DbParameter[] myDbParameters);
234 #endregion
235
236 IDataReader ExecuteReader(CommandType myCommandType, String sqlQuery, String[] names, Object[] values)#region IDataReader ExecuteReader(CommandType myCommandType, String sqlQuery, String[] names, Object[] values)
237 /**//// <summary>
238 /// 执行查询
239 /// </summary>
240 /// <param name="myCommandType">命令分类</param>
241 /// <param name="sqlQuery">sql查询</param>
242 /// <param name="names">参数名</param>
243 /// <param name="values">参数值</param>
244 /// <returns>结果集流</returns>
245 IDataReader ExecuteReader(CommandType myCommandType, String sqlQuery, String[] names, Object[] values);
246 #endregion
247
248
249 int ExecuteNonQuery(String sqlQuery)#region int ExecuteNonQuery(String sqlQuery)
250 /**//// <summary>
251 /// 执行查询, SQL BUILDER 用了这个东西?参数需要保存, 不能丢失.
252 /// </summary>
253 /// <param name="sqlQuery">sql查询</param>
254 /// <returns>影响行数</returns>
255 int ExecuteNonQuery(String sqlQuery);
256 #endregion
257
258 int ExecuteNonQuery(String sqlQuery, DbParameter[] myDbParameters);#region int ExecuteNonQuery(String sqlQuery, DbParameter[] myDbParameters);
259 /**//// <summary>
260 /// 执行查询
261 /// </summary>
262 /// <param name="sqlQuery">sql查询</param>
263 /// <param name="myDbParameterCollection">参数集</param>
264 /// <returns>影响行数</returns>
265 int ExecuteNonQuery(String sqlQuery, DbParameter[] myDbParameters);
266 #endregion
267
268 int ExecuteNonQuery(String sqlQuery, String name, Object value)#region int ExecuteNonQuery(String sqlQuery, String name, Object value)
269 /**//// <summary>
270 /// 执行查询
271 /// </summary>
272 /// <param name="myDataSet">数据集</param>
273 /// <param name="sqlQuery">sql查询</param>
274 /// <param name="name">参数名</param>
275 /// <param name="value">参数值</param>
276 /// <returns>影响行数</returns>
277 int ExecuteNonQuery(String sqlQuery, String name, Object value);
278 #endregion
279
280 int ExecuteNonQuery(String sqlQuery, String[] names, Object[] values)#region int ExecuteNonQuery(String sqlQuery, String[] names, Object[] values)
281 /**//// <summary>
282 /// 执行查询
283 /// </summary>
284 /// <param name="sqlQuery">sql查询</param>
285 /// <param name="names">参数名</param>
286 /// <param name="values">参数值</param>
287 /// <returns>影响行数</returns>
288 int ExecuteNonQuery(String sqlQuery, String[] names, Object[] values);
289 #endregion
290
291 int ExecuteNonQuery(CommandType myCommandType, String sqlQuery, DbParameter[] myDbParameters)#region int ExecuteNonQuery(CommandType myCommandType, String sqlQuery, DbParameter[] myDbParameters)
292 /**//// <summary>
293 /// 执行查询
294 /// </summary>
295 /// <param name="myCommandType">命令分类</param>
296 /// <param name="sqlQuery">sql查询</param>
297 /// <param name="myDbParameterCollection">参数集</param>
298 /// <returns>影响行数</returns>
299 int ExecuteNonQuery(CommandType myCommandType, String sqlQuery, DbParameter[] myDbParameters);
300 #endregion
301
302 int ExecuteNonQuery(CommandType myCommandType, String sqlQuery, String[] names, Object[] values)#region int ExecuteNonQuery(CommandType myCommandType, String sqlQuery, String[] names, Object[] values)
303 /**//// <summary>
304 /// 执行查询
305 /// </summary>
306 /// <param name="myCommandType">命令分类</param>
307 /// <param name="sqlQuery">sql查询</param>
308 /// <param name="names">参数名</param>
309 /// <param name="values">参数值</param>
310 /// <returns>影响行数</returns>
311 int ExecuteNonQuery(CommandType myCommandType, String sqlQuery, String[] names, Object[] values);
312 #endregion
313
314 int ExecuteNonQuery(IDbTransaction myOleDbTransaction, CommandType myCommandType, String sqlQuery, DbParameter[] myDbParameters)#region int ExecuteNonQuery(IDbTransaction myOleDbTransaction, CommandType myCommandType, String sqlQuery, DbParameter[] myDbParameters)
315 /**//// <summary>
316 /// 执行查询
317 /// </summary>
318 /// <param name="myOleDbTransaction">数据库事务</param>
319 /// <param name="myCommandType">命令分类</param>
320 /// <param name="sqlQuery">sql查询</param>
321 /// <param name="myDbParameterCollection">参数集</param>
322 /// <returns>影响行数</returns>
323 int ExecuteNonQuery(IDbTransaction myOleDbTransaction, CommandType myCommandType, String sqlQuery, DbParameter[] myDbParameters);
324 #endregion
325
326 int ExecuteNonQuery(IDbTransaction myOleDbTransaction, CommandType myCommandType, String sqlQuery, String[] names, Object[] values)#region int ExecuteNonQuery(IDbTransaction myOleDbTransaction, CommandType myCommandType, String sqlQuery, String[] names, Object[] values)
327 /**//// <summary>
328 /// 执行查询
329 /// </summary>
330 /// <param name="myOleDbTransaction">数据库事务</param>
331 /// <param name="myCommandType">命令分类</param>
332 /// <param name="sqlQuery">sql查询</param>
333 /// <param name="names">参数名</param>
334 /// <param name="values">参数值</param>
335 /// <returns>影响行数</returns>
336 int ExecuteNonQuery(IDbTransaction myOleDbTransaction, CommandType myCommandType, String sqlQuery, String[] names, Object[] values);
337 #endregion
338
339
340 Object ExecuteScalar(String sqlQuery)#region Object ExecuteScalar(String sqlQuery)
341 /**//// <summary>
342 /// 执行查询
343 /// </summary>
344 /// <param name="sqlQuery">sql查询</param>
345 /// <returns>Object</returns>
346 Object ExecuteScalar(String sqlQuery);
347 #endregion
348
349 Object ExecuteScalar(String sqlQuery, DbParameter[] myDbParameters)#region Object ExecuteScalar(String sqlQuery, DbParameter[] myDbParameters)
350 /**//// <summary>
351 /// 执行查询
352 /// </summary>
353 /// <param name="sqlQuery">sql查询</param>
354 /// <param name="myDbParameterCollection">参数集</param>
355 /// <returns>Object</returns>
356 Object ExecuteScalar(String sqlQuery, DbParameter[] myDbParameters);
357 #endregion
358
359 Object ExecuteScalar(String sqlQuery, String name, Object value)#region Object ExecuteScalar(String sqlQuery, String name, Object value)
360 /**//// <summary>
361 /// 执行查询
362 /// </summary>
363 /// <param name="sqlQuery">sql查询</param>
364 /// <param name="name">参数名</param>
365 /// <param name="value">参数值</param>
366 /// <returns>Object</returns>
367 Object ExecuteScalar(DataSet myDataSet, String sqlQuery, String name, Object value);
368 #endregion
369
370 Object ExecuteScalar(String sqlQuery, String[] names, Object[] values)#region Object ExecuteScalar(String sqlQuery, String[] names, Object[] values)
371 /**//// <summary>
372 /// 执行查询
373 /// </summary>
374 /// <param name="sqlQuery">sql查询</param>
375 /// <param name="names">参数名集</param>
376 /// <param name="values">参数值集</param>
377 /// <returns>Object</returns>
378 Object ExecuteScalar(String sqlQuery, String[] names, Object[] values);
379 #endregion
380
381 Object ExecuteScalar(CommandType myCommandType, String sqlQuery, DbParameter[] myDbParameters)#region Object ExecuteScalar(CommandType myCommandType, String sqlQuery, DbParameter[] myDbParameters)
382 /**//// <summary>
383 /// 执行查询
384 /// </summary>
385 /// <param name="myCommandType">命令分类</param>
386 /// <param name="sqlQuery">sql查询</param>
387 /// <param name="myDbParameterCollection">参数集</param>
388 /// <returns>Object</returns>
389 Object ExecuteScalar(CommandType myCommandType, String sqlQuery, DbParameter[] myDbParameters);
390 #endregion
391
392 Object ExecuteScalar(CommandType myCommandType, String sqlQuery, String[] names, Object[] values)#region Object ExecuteScalar(CommandType myCommandType, String sqlQuery, String[] names, Object[] values)
393 /**//// <summary>
394 /// 执行查询
395 /// </summary>
396 /// <param name="myCommandType">命令分类</param>
397 /// <param name="sqlQuery">sql查询</param>
398 /// <param name="names">参数名集</param>
399 /// <param name="values">参数值集</param>
400 /// <returns>Object</returns>
401 Object ExecuteScalar(CommandType myCommandType, String sqlQuery, String[] names, Object[] values);
402 #endregion
403
404 Object ExecuteScalar(IDbTransaction myOleDbTransaction, CommandType myCommandType, String sqlQuery, DbParameter[] myDbParameters)#region Object ExecuteScalar(IDbTransaction myOleDbTransaction, CommandType myCommandType, String sqlQuery, DbParameter[] myDbParameters)
405 /**//// <summary>
406 /// 执行查询
407 /// </summary>
408 /// <param name="myOleDbTransaction">数据库事务</param>
409 /// <param name="myCommandType">命令分类</param>
410 /// <param name="sqlQuery">sql查询</param>
411 /// <param name="myDbParameterCollection">参数集</param>
412 /// <returns>Object</returns>
413 Object ExecuteScalar(IDbTransaction myOleDbTransaction, CommandType myCommandType, String sqlQuery, DbParameter[] myDbParameters);
414 #endregion
415
416 Object ExecuteScalar(IDbTransaction myOleDbTransaction, CommandType myCommandType, String sqlQuery, String[] names, Object[] values)#region Object ExecuteScalar(IDbTransaction myOleDbTransaction, CommandType myCommandType, String sqlQuery, String[] names, Object[] values)
417 /**//// <summary>
418 /// 执行查询
419 /// </summary>
420 /// <param name="myOleDbTransaction">数据库事务</param>
421 /// <param name="myCommandType">命令分类</param>
422 /// <param name="sqlQuery">sql查询</param>
423 /// <param name="names">参数名集</param>
424 /// <param name="values">参数值集</param>
425 /// <returns>Object</returns>
426 Object ExecuteScalar(IDbTransaction myOleDbTransaction, CommandType myCommandType, String sqlQuery, String[] names, Object[] values);
427 #endregion
428
429
430 DataTable Fill(DataTable myDataTable, String sqlQuery)#region DataTable Fill(DataTable myDataTable, String sqlQuery)
431 /**//// <summary>
432 /// 填充数据表
433 /// </summary>
434 /// <param name="myDataTable">目标数据表</param>
435 /// <param name="sqlQuery">查询</param>
436 /// <returns>数据表</returns>
437 DataTable Fill(DataTable myDataTable, String sqlQuery);
438 #endregion
439
440 DataTable Fill(DataTable myDataTable, String sqlQuery, DbParameter[] myDbParameters)#region DataTable Fill(DataTable myDataTable, String sqlQuery, DbParameter[] myDbParameters)
441 /**//// <summary>
442 /// 填充数据表
443 /// </summary>
444 /// <param name="myDataTable">目标数据表</param>
445 /// <param name="sqlQuery">sql查询</param>
446 /// <param name="myDbParameterCollection">参数集</param>
447 /// <returns>数据表</returns>
448 DataTable Fill(DataTable myDataTable, String sqlQuery, DbParameter[] myDbParameters);
449 #endregion
450
451 DataTable Fill(DataTable myDataTable, String sqlQuery, String name, Object value)#region DataTable Fill(DataTable myDataTable, String sqlQuery, String name, Object value)
452 /**//// <summary>
453 /// 填充数据表
454 /// </summary>
455 /// <param name="myDataTable">目标数据表</param>
456 /// <param name="sqlQuery">sql查询</param>
457 /// <param name="name">参数名</param>
458 /// <param name="value">参数值</param>
459 /// <returns>数据表</returns>
460 DataTable Fill(DataTable myDataTable, String sqlQuery, String name, Object value);
461 #endregion
462
463 DataTable Fill(DataTable myDataTable, String sqlQuery, String[] names, Object[] values)#region DataTable Fill(DataTable myDataTable, String sqlQuery, String[] names, Object[] values)
464 /**//// <summary>
465 /// 填充数据表
466 /// </summary>
467 /// <param name="myDataSet">目标数据表</param>
468 /// <param name="sqlQuery">sql查询</param>
469 /// <param name="names">参数名集</param>
470 /// <param name="values">参数值集</param>
471 /// <returns>数据表</returns>
472 DataTable Fill(DataTable myDataTable, String sqlQuery, String[] names, Object[] values);
473 #endregion
474
475 DataTable Fill(DataTable myDataTable, CommandType myCommandType, String sqlQuery, DbParameter[] myDbParameters)#region DataTable Fill(DataTable myDataTable, CommandType myCommandType, String sqlQuery, DbParameter[] myDbParameters)
476 /**//// <summary>
477 /// 填充数据表
478 /// </summary>
479 /// <param name="myDataSet">目标数据表</param>
480 /// <param name="myCommandType">命令分类</param>
481 /// <param name="sqlQuery">sql查询</param>
482 /// <param name="myDbParameterCollection">参数集</param>
483 /// <returns>数据表</returns>
484 DataTable Fill(DataTable myDataTable, CommandType myCommandType, String sqlQuery, DbParameter[] myDbParameters);
485 #endregion
486
487 DataTable Fill(DataTable myDataTable, CommandType myCommandType, String sqlQuery, String[] names, Object[] values)#region DataTable Fill(DataTable myDataTable, CommandType myCommandType, String sqlQuery, String[] names, Object[] values)
488 /**//// <summary>
489 /// 填充数据表
490 /// </summary>
491 /// <param name="myDataSet">目标数据表</param>
492 /// <param name="myCommandType">命令分类</param>
493 /// <param name="sqlQuery">sql查询</param>
494 /// <param name="names">参数名</param>
495 /// <param name="values">参数值</param>
496 /// <returns>数据表</returns>
497 DataTable Fill(DataTable myDataTable, CommandType myCommandType, String sqlQuery, String[] names, Object[] values);
498 #endregion
499
500
501 DataSet Fill(DataSet myDataSet, String sqlQuery, String tableName)#region DataSet Fill(DataSet myDataSet, String sqlQuery, String tableName)
502 /**//// <summary>
503 /// 填充数据集
504 /// </summary>
505 /// <param name="myDataSet">目标数据集</param>
506 /// <param name="sqlQuery">查询</param>
507 /// <param name="tableName">填充表</param>
508 /// <returns>数据集</returns>
509 DataSet Fill(DataSet myDataSet, String sqlQuery, String tableName);
510 #endregion
511
512 DataSet Fill(DataSet myDataSet, String sqlQuery, String tableName, DbParameter[] myDbParameters)#region DataSet Fill(DataSet myDataSet, String sqlQuery, String tableName, DbParameter[] myDbParameters)
513 /**//// <summary>
514 /// 填充数据集
515 /// </summary>
516 /// <param name="myDataSet">数据集</param>
517 /// <param name="sqlQuery">sql查询</param>
518 /// <param name="tableName">填充表</param>
519 /// <param name="myDbParameterCollection">参数集</param>
520 /// <returns>数据集</returns>
521 DataSet Fill(DataSet myDataSet, String sqlQuery, String tableName, DbParameter[] myDbParameters);
522 #endregion
523
524 DataSet Fill(DataSet myDataSet, String sqlQuery, String tableName, String name, Object value)#region DataSet Fill(DataSet myDataSet, String sqlQuery, String tableName, String name, Object value)
525 /**//// <summary>
526 /// 填充数据集
527 /// </summary>
528 /// <param name="myDataSet">数据集</param>
529 /// <param name="sqlQuery">sql查询</param>
530 /// <param name="tableName">填充表</param>
531 /// <param name="name">参数名</param>
532 /// <param name="value">参数值</param>
533 /// <returns>数据集</returns>
534 DataSet Fill(DataSet myDataSet, String sqlQuery, String tableName, String name, Object value);
535 #endregion
536
537 DataSet Fill(DataSet myDataSet, String sqlQuery, String tableName, String[] names, Object[] values)#region DataSet Fill(DataSet myDataSet, String sqlQuery, String tableName, String[] names, Object[] values)
538 /**//// <summary>
539 /// 填充数据集
540 /// </summary>
541 /// <param name="myDataSet">数据集</param>
542 /// <param name="sqlQuery">sql查询</param>
543 /// <param name="tableName">填充表</param>
544 /// <param name="names">参数名集</param>
545 /// <param name="values">参数值集</param>
546 /// <returns>数据集</returns>
547 DataSet Fill(DataSet myDataSet, String sqlQuery, String tableName, String[] names, Object[] values);
548 #endregion
549
550 DataSet Fill(DataSet myDataSet, CommandType myCommandType, String sqlQuery, String tableName, DbParameter[] myDbParameters)#region DataSet Fill(DataSet myDataSet, CommandType myCommandType, String sqlQuery, String tableName, DbParameter[] myDbParameters)
551 /**//// <summary>
552 /// 填充数据集
553 /// </summary>
554 /// <param name="myDataSet">数据集</param>
555 /// <param name="myCommandType">命令分类</param>
556 /// <param name="sqlQuery">sql查询</param>
557 /// <param name="tableName">填充表</param>
558 /// <param name="myDbParameterCollection">参数集</param>
559 /// <returns>数据集</returns>
560 DataSet Fill(DataSet myDataSet, CommandType myCommandType, String sqlQuery, String tableName, DbParameter[] myDbParameters);
561 #endregion
562
563 DataSet Fill(DataSet myDataSet, CommandType myCommandType, String sqlQuery, String tableName, String[] names, Object[] values)#region DataSet Fill(DataSet myDataSet, CommandType myCommandType, String sqlQuery, String tableName, String[] names, Object[] values)
564 /**//// <summary>
565 /// 填充数据集
566 /// </summary>
567 /// <param name="myDataSet">数据集</param>
568 /// <param name="myCommandType">命令分类</param>
569 /// <param name="sqlQuery">sql查询</param>
570 /// <param name="tableName">填充表</param>
571 /// <param name="names">参数名集</param>
572 /// <param name="values">参数值集</param>
573 /// <returns>数据集</returns>
574 DataSet Fill(DataSet myDataSet, CommandType myCommandType, String sqlQuery, String tableName, String[] names, Object[] values);
575 #endregion
576
577
578 int ExecuteProcedure(String procedureName)#region int ExecuteProcedure(String procedureName)
579 /**//// <summary>
580 /// 执行数据库查询
581 /// </summary>
582 /// <param name="procedureName">存储过程</param>
583 /// <returns>影响行数</returns>
584 int ExecuteProcedure(String procedureName);
585 #endregion
586
587 int ExecuteProcedure(String procedureName, DbParameter[] myDbParameters)#region int ExecuteProcedure(String procedureName, DbParameter[] myDbParameters)
588 /**//// <summary>
589 /// 执行存储过程
590 /// </summary>
591 /// <param name="procedureName">存储过程名</param>
592 /// <param name="myDbParameterCollection">参数集</param>
593 /// <returns>影响行数</returns>
594 int ExecuteProcedure(String procedureName, DbParameter[] myDbParameters);
595 #endregion
596
597 int ExecuteProcedure(String procedureName, String name, String value)#region int ExecuteProcedure(String procedureName, String name, String value)
598 /**//// <summary>
599 /// 执行存储过程
600 /// </summary>
601 /// <param name="procedureName">存储过程名</param>
602 /// <param name="name">参数名</param>
603 /// <param name="value">参数值</param>
604 /// <returns>影响行数</returns>
605 int ExecuteProcedure(String procedureName, String name, String value);
606 #endregion
607
608 int ExecuteProcedure(String procedureName, String[] names, Object[] values)#region int ExecuteProcedure(String procedureName, String[] names, Object[] values)
609 /**//// <summary>
610 /// 执行数据库脚本
611 /// </summary>
612 /// <param name="procedureName">存储过程</param>
613 /// <param name="names">参数名集</param>
614 /// <param name="values">参数值集</param>
615 /// <returns>影响行数</returns>
616 int ExecuteProcedure(String procedureName, String[] names, Object[] values);
617 #endregion
618
619 DataSet ExecuteProcedureForDataSet(DataSet myDataSet, String procedureName, String tableName, DbParameter[] myDbParameters)#region DataSet ExecuteProcedureForDataSet(DataSet myDataSet, String procedureName, String tableName, DbParameter[] myDbParameters)
620 /**//// <summary>
621 /// 执行数据库脚本
622 /// </summary>
623 /// <param name="myDataSet">数据集</param>
624 /// <param name="procedureName">存储过程</param>
625 /// <param name="tableName">填充表</param>
626 /// <param name="myDbParameterCollection">参数集</param>
627 /// <returns>数据集</returns>
628 DataSet ExecuteProcedureForDataSet(DataSet myDataSet, String procedureName, String tableName, DbParameter[] myDbParameters);
629 #endregion
630
631 DataSet ExecuteProcedureForDataSet(DataSet myDataSet, String procedureName, String tableName, String[] names, Object[] values)#region DataSet ExecuteProcedureForDataSet(DataSet myDataSet, String procedureName, String tableName, String[] names, Object[] values)
632 /**//// <summary>
633 /// 执行数据库脚本
634 /// </summary>
635 /// <param name="myDataSet">数据集</param>
636 /// <param name="procedureName">存储过程</param>
637 /// <param name="tableName">填充表</param>
638 /// <param name="names">参数名集</param>
639 /// <param name="values">参数值集</param>
640 /// <returns>数据集</returns>
641 DataSet ExecuteProcedureForDataSet(DataSet myDataSet, String procedureName, String tableName, String[] names, Object[] values);
642 #endregion
643
644
645 IDbTransaction BeginTransaction()#region IDbTransaction BeginTransaction()
646 /**//// <summary>
647 /// 事务开始
648 /// </summary>
649 /// <returns>事务</returns>
650 IDbTransaction BeginTransaction();
651 #endregion
652
653 void CommitTransaction()#region void CommitTransaction()
654 /**//// <summary>
655 /// 递交事务
656 /// </summary>
657 void CommitTransaction();
658 #endregion
659
660 void RollbackTransaction()#region void RollbackTransaction()
661 /**//// <summary>
662 /// 回滚事务
663 /// </summary>
664 void RollbackTransaction();
665 #endregion
666
667 void ExecuteNonQueryAsync(CommandType myCommandType, String sqlQuery, DbParameter[] myDbParameters);#region void ExecuteNonQueryAsync(CommandType myCommandType, String sqlQuery, DbParameter[] myDbParameters);
668 /**//// <summary>
669 /// 异步调用数据库查询
670 /// </summary>
671 /// <param name="myCommandType">命令分类</param>
672 /// <param name="sqlQuery">sql查询</param>
673 /// <param name="myDbParameterCollection">参数集</param>
674 /// void ExecuteNonQueryAsync(CommandType myCommandType, String sqlQuery, DbParameter[] myDbParameters);
675 #endregion
676
677 void ExecuteNonQueryAsync(CommandType myCommandType, String sqlQuery, String[] names, Object[] values)#region void ExecuteNonQueryAsync(CommandType myCommandType, String sqlQuery, String[] names, Object[] values)
678 /**//// <summary>
679 /// 异步调用数据库查询
680 /// </summary>
681 /// <param name="myCommandType">命令分类</param>
682 /// <param name="sqlQuery">sql查询</param>
683 /// <param name="names">参数名集</param>
684 /// <param name="values">参数值集</param>
685 void ExecuteNonQueryAsync(CommandType myCommandType, String sqlQuery, String[] names, Object[] values);
686 #endregion
687
688 void ExecuteProcedureAsync(String procedureName, DbParameter[] myDbParameters)#region void ExecuteProcedureAsync(String procedureName, DbParameter[] myDbParameters)
689 /**//// <summary>
690 /// 异步调用数据库查询
691 /// </summary>
692 /// <param name="procedureName">存储过程</param>
693 /// <param name="myDbParameterCollection">参数集</param>
694 /// void ExecuteProcedureAsync(String procedureName, DbParameter[] myDbParameters);
695 #endregion
696
697 void ExecuteProcedureAsync(String procedureName, String[] names, Object[] values)#region void ExecuteProcedureAsync(String procedureName, String[] names, Object[] values)
698 /**//// <summary>
699 /// 异步调用数据库查询
700 /// </summary>
701 /// <param name="procedureName">存储过程</param>
702 /// <param name="names">参数名集</param>
703 /// <param name="values">参数值集</param>
704 void ExecuteProcedureAsync(String procedureName, String[] names, Object[] values);
705 #endregion
706
707
708 void Close()#region void Close()
709 /**//// <summary>
710 /// 关闭数据库连接
711 /// </summary>
712 void Close();
713 #endregion
714 }
715}