DBManager.cs 89 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440
  1. using System;
  2. using System.Data;
  3. using System.Data.OracleClient;
  4. using System.Collections;
  5. using System.Runtime.Remoting;
  6. using System.Runtime.Remoting.Channels;
  7. using System.Runtime.Remoting.Channels.Tcp;
  8. using System.Threading;
  9. using NHibernate;
  10. using NHibernate.Cfg;
  11. namespace STMes
  12. {
  13. /// <summary>
  14. /// DBManager 的摘要说明。
  15. /// </summary>
  16. public class DBManager : IDisposable
  17. {
  18. /// <summary>
  19. /// 初始化
  20. /// </summary>
  21. public DBManager()
  22. {
  23. //InitDBManager("MesDB", "A");
  24. InitDBManager("MesDB");
  25. }
  26. /// <summary>
  27. /// 初始化
  28. /// </summary>
  29. /// <param name="dbName">数据库名称</param>
  30. public DBManager(string dbName)
  31. {
  32. //InitDBManager(dbName, "A");
  33. InitDBManager(dbName);
  34. }
  35. ///// <summary>
  36. ///// 初始化
  37. ///// </summary>
  38. ///// <param name="dbName">数据库名称</param>
  39. ///// <param name="priority">优先级</param>
  40. //public DBManager(string dbName, string priority)
  41. //{
  42. // InitDBManager(dbName, priority);
  43. //}
  44. public void Dispose() { }
  45. /// <summary>
  46. /// 获取上次执行时最后一个错误信息,无错误则返回空字符串
  47. /// </summary>
  48. /// <returns>错误信息</returns>
  49. public string GetLastError()
  50. {
  51. return _errMsg;
  52. }
  53. /// <summary>
  54. /// 判断DBManager是否有效
  55. /// </summary>
  56. /// <returns>是否有效</returns>
  57. public bool IsValid()
  58. {
  59. return _valid;
  60. }
  61. /// <summary>
  62. /// 获取数据库类型,用字符串"SQLServer","Oracle", "OleDb"分别表示不同类型的数据库
  63. /// </summary>
  64. /// <returns>数据库类型</returns>
  65. public string GetDbType()
  66. {
  67. string dbType = "";
  68. try
  69. {
  70. dbType = _dbProxy.GetDbType(_dbName, out _errMsg);
  71. }
  72. catch (Exception ex)
  73. {
  74. _valid = false;
  75. _errMsg = ex.Message;
  76. }
  77. return dbType;
  78. }
  79. //获取数据库类型,用字符串"SQLServer","Oracle", "OleDb"分别表示不同类型的数据库
  80. public string GetDbType(out string err)
  81. {
  82. string dbType = "";
  83. err = "";
  84. try
  85. {
  86. dbType = _dbProxy.GetDbType(_dbName, out err);
  87. _errMsg = err;
  88. }
  89. catch (Exception ex)
  90. {
  91. _valid = false;
  92. _errMsg = err = ex.Message;
  93. }
  94. return dbType;
  95. }
  96. #region add 马亮 2011-10-21
  97. /// <summary>
  98. /// 分页返回查询数据[只支持Oracle数据库]
  99. /// </summary>
  100. /// <param name="sql"></param>
  101. /// <param name="pageIndex"></param>
  102. /// <param name="pageSize"></param>
  103. /// <param name="recordCount"></param>
  104. /// <param name="pageCount"></param>
  105. /// <param name="err"></param>
  106. /// <returns></returns>
  107. public DataSet ExecuteDataPageQuery(string sql, int pageIndex, int pageSize, out int recordCount, out int pageCount, out string err)
  108. {
  109. DataPage dpage = new DataPage(_dbProxy, _dbName, _priority);
  110. dpage.InitDataPage(sql, pageIndex, pageSize);
  111. _valid = dpage._valid;
  112. _errMsg = dpage._errMsg;
  113. err = _errMsg;
  114. recordCount = dpage.RecordCount;
  115. pageCount = dpage.PageCount;
  116. return dpage.Result;
  117. }
  118. /// <summary>
  119. /// 分页返回查询数据[只支持Oracle数据库]
  120. /// </summary>
  121. /// <param name="sql"></param>
  122. /// <param name="pageIndex"></param>
  123. /// <param name="pageSize"></param>
  124. /// <param name="Params"></param>
  125. /// <param name="Values"></param>
  126. /// <param name="recordCount"></param>
  127. /// <param name="pageCount"></param>
  128. /// <param name="err"></param>
  129. /// <returns></returns>
  130. public DataSet ExecuteDataPageQuery(string sql, int pageIndex, int pageSize, IDataParameter[] Params, object[] Values, out int recordCount, out int pageCount, out string err)
  131. {
  132. DataPage dpage = new DataPage(_dbProxy, _dbName, _priority);
  133. dpage.InitDataPage(sql, pageIndex, pageSize, Params, Values);
  134. _valid = dpage._valid;
  135. _errMsg = dpage._errMsg;
  136. err = _errMsg;
  137. recordCount = dpage.RecordCount;
  138. pageCount = dpage.PageCount;
  139. return dpage.Result;
  140. }
  141. #endregion
  142. //执行SQL语句,返回DataSet
  143. public DataSet ExecuteQuery(string Sql, Guid guid)
  144. {
  145. DataSet ds = null;
  146. try
  147. {
  148. ds = _dbProxy.ExecuteQuery(_dbName, _priority, guid, Sql, CommandType.Text, null, null, out _errMsg);
  149. }
  150. catch (Exception ex)
  151. {
  152. _valid = false;
  153. _errMsg = ex.Message;
  154. }
  155. return ds;
  156. }
  157. public DataSet ExecuteQuery(string Sql)
  158. {
  159. DataSet ds = null;
  160. try
  161. {
  162. ds = _dbProxy.ExecuteQuery(_dbName, _priority, Sql, CommandType.Text, null, null, out _errMsg);
  163. }
  164. catch (Exception ex)
  165. {
  166. _valid = false;
  167. _errMsg = ex.Message;
  168. }
  169. return ds;
  170. }
  171. //执行SQL语句,返回DataSet
  172. public DataSet ExecuteQuery(string Sql, Guid guid, out string err)
  173. {
  174. err = "";
  175. DataSet ds = new DataSet();
  176. try
  177. {
  178. ds = _dbProxy.ExecuteQuery(_dbName, _priority, guid, Sql, CommandType.Text, null, null, out err);
  179. _errMsg = err;
  180. }
  181. catch (Exception ex)
  182. {
  183. _valid = false;
  184. err = _errMsg = ex.Message;
  185. }
  186. return ds;
  187. }
  188. public DataSet ExecuteQuery(string Sql, out string err)
  189. {
  190. err = "";
  191. DataSet ds = new DataSet();
  192. try
  193. {
  194. ds = _dbProxy.ExecuteQuery(_dbName, _priority, Sql, CommandType.Text, null, null, out err);
  195. _errMsg = err;
  196. }
  197. catch (Exception ex)
  198. {
  199. _valid = false;
  200. err = _errMsg = ex.Message;
  201. }
  202. return ds;
  203. }
  204. public DataSet ExecuteQuery(string Sql, out string err, bool ifDBLink)
  205. {
  206. err = "";
  207. DataSet ds = new DataSet();
  208. try
  209. {
  210. ds = _dbProxy.ExecuteQuery(_dbName, _priority, Sql, CommandType.Text, null, null, out err, ifDBLink);
  211. _errMsg = err;
  212. }
  213. catch (Exception ex)
  214. {
  215. _valid = false;
  216. err = _errMsg = ex.Message;
  217. }
  218. return ds;
  219. }
  220. //执行SQL语句,返回DataSet
  221. public DataSet ExecuteQuery(string Sql, CommandType cmdType, Guid guid)
  222. {
  223. DataSet ds = new DataSet();
  224. try
  225. {
  226. ds = _dbProxy.ExecuteQuery(_dbName, _priority, guid, Sql, cmdType, null, null, out _errMsg);
  227. }
  228. catch (Exception ex)
  229. {
  230. _valid = false;
  231. _errMsg = ex.Message;
  232. }
  233. return ds;
  234. }
  235. public DataSet ExecuteQuery(string Sql, CommandType cmdType)
  236. {
  237. DataSet ds = new DataSet();
  238. try
  239. {
  240. ds = _dbProxy.ExecuteQuery(_dbName, _priority, Sql, cmdType, null, null, out _errMsg);
  241. }
  242. catch (Exception ex)
  243. {
  244. _valid = false;
  245. _errMsg = ex.Message;
  246. }
  247. return ds;
  248. }
  249. //执行SQL语句,返回DataSet
  250. public DataSet ExecuteQuery(string Sql, CommandType cmdType, Guid guid, out string err)
  251. {
  252. err = "";
  253. DataSet ds = new DataSet();
  254. try
  255. {
  256. ds = _dbProxy.ExecuteQuery(_dbName, _priority, guid, Sql, cmdType, null, null, out err);
  257. _errMsg = err;
  258. }
  259. catch (Exception ex)
  260. {
  261. _valid = false;
  262. err = _errMsg = ex.Message;
  263. }
  264. return ds;
  265. }
  266. public DataSet ExecuteQuery(string Sql, CommandType cmdType, out string err)
  267. {
  268. err = "";
  269. DataSet ds = new DataSet();
  270. try
  271. {
  272. ds = _dbProxy.ExecuteQuery(_dbName, _priority, Sql, cmdType, null, null, out err);
  273. _errMsg = err;
  274. }
  275. catch (Exception ex)
  276. {
  277. _valid = false;
  278. err = _errMsg = ex.Message;
  279. }
  280. return ds;
  281. }
  282. //执行带参数的SQL语句,返回DataSet
  283. public DataSet ExecuteQuery(string Sql, IDataParameter[] Params, object[] Values, Guid guid)
  284. {
  285. DataSet ds = new DataSet();
  286. try
  287. {
  288. //给所有的参数赋值
  289. if (Params != null && Values != null)
  290. {
  291. string[] ParameterNames = new string[Params.Length];
  292. DbType[] DbTypes = new DbType[Params.Length];
  293. ParameterDirection[] Directions = new ParameterDirection[Params.Length];
  294. bool[] IsNullables = new bool[Params.Length];
  295. string[] SourceColumns = new string[Params.Length];
  296. DataRowVersion[] SourceVersions = new DataRowVersion[Params.Length];
  297. for (int i = 0; i < Params.Length; i++)
  298. {
  299. ParameterNames[i] = Params[i].ParameterName;
  300. DbTypes[i] = Params[i].DbType;
  301. Directions[i] = Params[i].Direction;
  302. IsNullables[i] = Params[i].IsNullable;
  303. SourceColumns[i] = Params[i].SourceColumn;
  304. SourceVersions[i] = Params[i].SourceVersion;
  305. }
  306. ArrayList OutputValues = null;
  307. ds = _dbProxy.ExecuteQuery(_dbName, _priority, guid, Sql, CommandType.Text, ParameterNames, DbTypes, Directions, IsNullables, SourceColumns, SourceVersions, Values, ref OutputValues, out _errMsg);
  308. }
  309. else
  310. {
  311. ds = _dbProxy.ExecuteQuery(_dbName, _priority, guid, Sql, CommandType.Text, null, null, out _errMsg);
  312. }
  313. }
  314. catch (Exception ex)
  315. {
  316. _valid = false;
  317. _errMsg = ex.Message;
  318. }
  319. return ds;
  320. }
  321. public DataSet ExecuteQuery(string Sql, IDataParameter[] Params, object[] Values)
  322. {
  323. DataSet ds = new DataSet();
  324. try
  325. {
  326. //给所有的参数赋值
  327. if (Params != null && Values != null)
  328. {
  329. string[] ParameterNames = new string[Params.Length];
  330. DbType[] DbTypes = new DbType[Params.Length];
  331. ParameterDirection[] Directions = new ParameterDirection[Params.Length];
  332. bool[] IsNullables = new bool[Params.Length];
  333. string[] SourceColumns = new string[Params.Length];
  334. DataRowVersion[] SourceVersions = new DataRowVersion[Params.Length];
  335. for (int i = 0; i < Params.Length; i++)
  336. {
  337. ParameterNames[i] = Params[i].ParameterName;
  338. DbTypes[i] = Params[i].DbType;
  339. Directions[i] = Params[i].Direction;
  340. IsNullables[i] = Params[i].IsNullable;
  341. SourceColumns[i] = Params[i].SourceColumn;
  342. SourceVersions[i] = Params[i].SourceVersion;
  343. }
  344. ArrayList OutputValues = null;
  345. ds = _dbProxy.ExecuteQuery(_dbName, _priority, Sql, CommandType.Text, ParameterNames, DbTypes, Directions, IsNullables, SourceColumns, SourceVersions, Values, ref OutputValues, out _errMsg);
  346. }
  347. else
  348. {
  349. ds = _dbProxy.ExecuteQuery(_dbName, _priority, Sql, CommandType.Text, null, null, out _errMsg);
  350. }
  351. }
  352. catch (Exception ex)
  353. {
  354. _valid = false;
  355. _errMsg = ex.Message;
  356. }
  357. return ds;
  358. }
  359. //执行带参数的SQL语句,返回DataSet
  360. public DataSet ExecuteQuery(string Sql, IDataParameter[] Params, object[] Values, ref ArrayList OutputValues, Guid guid)
  361. {
  362. DataSet ds = new DataSet();
  363. try
  364. {
  365. //给所有的参数赋值
  366. if (Params != null && Values != null)
  367. {
  368. string[] ParameterNames = new string[Params.Length];
  369. DbType[] DbTypes = new DbType[Params.Length];
  370. ParameterDirection[] Directions = new ParameterDirection[Params.Length];
  371. bool[] IsNullables = new bool[Params.Length];
  372. string[] SourceColumns = new string[Params.Length];
  373. DataRowVersion[] SourceVersions = new DataRowVersion[Params.Length];
  374. for (int i = 0; i < Params.Length; i++)
  375. {
  376. ParameterNames[i] = Params[i].ParameterName;
  377. DbTypes[i] = Params[i].DbType;
  378. Directions[i] = Params[i].Direction;
  379. IsNullables[i] = Params[i].IsNullable;
  380. SourceColumns[i] = Params[i].SourceColumn;
  381. SourceVersions[i] = Params[i].SourceVersion;
  382. }
  383. ds = _dbProxy.ExecuteQuery(_dbName, _priority, guid, Sql, CommandType.Text, ParameterNames, DbTypes, Directions, IsNullables, SourceColumns, SourceVersions, Values, ref OutputValues, out _errMsg);
  384. }
  385. else
  386. {
  387. ds = _dbProxy.ExecuteQuery(_dbName, _priority, guid, Sql, CommandType.Text, null, null, out _errMsg);
  388. }
  389. }
  390. catch (Exception ex)
  391. {
  392. _valid = false;
  393. _errMsg = ex.Message;
  394. }
  395. return ds;
  396. }
  397. public DataSet ExecuteQuery(string Sql, IDataParameter[] Params, object[] Values, ref ArrayList OutputValues)
  398. {
  399. DataSet ds = new DataSet();
  400. try
  401. {
  402. //给所有的参数赋值
  403. if (Params != null && Values != null)
  404. {
  405. string[] ParameterNames = new string[Params.Length];
  406. DbType[] DbTypes = new DbType[Params.Length];
  407. ParameterDirection[] Directions = new ParameterDirection[Params.Length];
  408. bool[] IsNullables = new bool[Params.Length];
  409. string[] SourceColumns = new string[Params.Length];
  410. DataRowVersion[] SourceVersions = new DataRowVersion[Params.Length];
  411. for (int i = 0; i < Params.Length; i++)
  412. {
  413. ParameterNames[i] = Params[i].ParameterName;
  414. DbTypes[i] = Params[i].DbType;
  415. Directions[i] = Params[i].Direction;
  416. IsNullables[i] = Params[i].IsNullable;
  417. SourceColumns[i] = Params[i].SourceColumn;
  418. SourceVersions[i] = Params[i].SourceVersion;
  419. }
  420. ds = _dbProxy.ExecuteQuery(_dbName, _priority, Sql, CommandType.Text, ParameterNames, DbTypes, Directions, IsNullables, SourceColumns, SourceVersions, Values, ref OutputValues, out _errMsg);
  421. }
  422. else
  423. {
  424. ds = _dbProxy.ExecuteQuery(_dbName, _priority, Sql, CommandType.Text, null, null, out _errMsg);
  425. }
  426. }
  427. catch (Exception ex)
  428. {
  429. _valid = false;
  430. _errMsg = ex.Message;
  431. }
  432. return ds;
  433. }
  434. //执行带参数的SQL语句,返回DataSet
  435. public DataSet ExecuteQuery(string Sql, IDataParameter[] Params, object[] Values, Guid guid, out string err)
  436. {
  437. err = "";
  438. DataSet ds = new DataSet();
  439. try
  440. {
  441. //给所有的参数赋值
  442. if (Params != null && Values != null)
  443. {
  444. string[] ParameterNames = new string[Params.Length];
  445. DbType[] DbTypes = new DbType[Params.Length];
  446. ParameterDirection[] Directions = new ParameterDirection[Params.Length];
  447. bool[] IsNullables = new bool[Params.Length];
  448. string[] SourceColumns = new string[Params.Length];
  449. DataRowVersion[] SourceVersions = new DataRowVersion[Params.Length];
  450. for (int i = 0; i < Params.Length; i++)
  451. {
  452. ParameterNames[i] = Params[i].ParameterName;
  453. DbTypes[i] = Params[i].DbType;
  454. Directions[i] = Params[i].Direction;
  455. IsNullables[i] = Params[i].IsNullable;
  456. SourceColumns[i] = Params[i].SourceColumn;
  457. SourceVersions[i] = Params[i].SourceVersion;
  458. }
  459. ArrayList OutputValues = null;
  460. ds = _dbProxy.ExecuteQuery(_dbName, _priority, guid, Sql, CommandType.Text, ParameterNames, DbTypes, Directions, IsNullables, SourceColumns, SourceVersions, Values, ref OutputValues, out err);
  461. }
  462. else
  463. {
  464. ds = _dbProxy.ExecuteQuery(_dbName, _priority, guid, Sql, CommandType.Text, null, null, out err);
  465. }
  466. _errMsg = err;
  467. }
  468. catch (Exception ex)
  469. {
  470. _valid = false;
  471. err = _errMsg = ex.Message;
  472. }
  473. return ds;
  474. }
  475. public DataSet ExecuteQuery(string Sql, IDataParameter[] Params, object[] Values, out string err)
  476. {
  477. err = "";
  478. DataSet ds = new DataSet();
  479. try
  480. {
  481. //给所有的参数赋值
  482. if (Params != null && Values != null)
  483. {
  484. string[] ParameterNames = new string[Params.Length];
  485. DbType[] DbTypes = new DbType[Params.Length];
  486. ParameterDirection[] Directions = new ParameterDirection[Params.Length];
  487. bool[] IsNullables = new bool[Params.Length];
  488. string[] SourceColumns = new string[Params.Length];
  489. DataRowVersion[] SourceVersions = new DataRowVersion[Params.Length];
  490. for (int i = 0; i < Params.Length; i++)
  491. {
  492. ParameterNames[i] = Params[i].ParameterName;
  493. DbTypes[i] = Params[i].DbType;
  494. Directions[i] = Params[i].Direction;
  495. IsNullables[i] = Params[i].IsNullable;
  496. SourceColumns[i] = Params[i].SourceColumn;
  497. SourceVersions[i] = Params[i].SourceVersion;
  498. }
  499. ArrayList OutputValues = null;
  500. ds = _dbProxy.ExecuteQuery(_dbName, _priority, Sql, CommandType.Text, ParameterNames, DbTypes, Directions, IsNullables, SourceColumns, SourceVersions, Values, ref OutputValues, out err);
  501. }
  502. else
  503. {
  504. ds = _dbProxy.ExecuteQuery(_dbName, _priority, Sql, CommandType.Text, null, null, out err);
  505. }
  506. _errMsg = err;
  507. }
  508. catch (Exception ex)
  509. {
  510. _valid = false;
  511. err = _errMsg = ex.Message;
  512. }
  513. return ds;
  514. }
  515. //执行带参数的SQL语句,返回DataSet
  516. public DataSet ExecuteQuery(string Sql, IDataParameter[] Params, object[] Values, ref ArrayList OutputValues, Guid guid, out string err)
  517. {
  518. err = "";
  519. DataSet ds = new DataSet();
  520. try
  521. {
  522. //给所有的参数赋值
  523. if (Params != null && Values != null)
  524. {
  525. string[] ParameterNames = new string[Params.Length];
  526. DbType[] DbTypes = new DbType[Params.Length];
  527. ParameterDirection[] Directions = new ParameterDirection[Params.Length];
  528. bool[] IsNullables = new bool[Params.Length];
  529. string[] SourceColumns = new string[Params.Length];
  530. DataRowVersion[] SourceVersions = new DataRowVersion[Params.Length];
  531. for (int i = 0; i < Params.Length; i++)
  532. {
  533. ParameterNames[i] = Params[i].ParameterName;
  534. DbTypes[i] = Params[i].DbType;
  535. Directions[i] = Params[i].Direction;
  536. IsNullables[i] = Params[i].IsNullable;
  537. SourceColumns[i] = Params[i].SourceColumn;
  538. SourceVersions[i] = Params[i].SourceVersion;
  539. }
  540. ds = _dbProxy.ExecuteQuery(_dbName, _priority, guid, Sql, CommandType.Text, ParameterNames, DbTypes, Directions, IsNullables, SourceColumns, SourceVersions, Values, ref OutputValues, out err);
  541. }
  542. else
  543. {
  544. ds = _dbProxy.ExecuteQuery(_dbName, _priority, guid, Sql, CommandType.Text, null, null, out err);
  545. }
  546. _errMsg = err;
  547. }
  548. catch (Exception ex)
  549. {
  550. _valid = false;
  551. err = _errMsg = ex.Message;
  552. }
  553. return ds;
  554. }
  555. public DataSet ExecuteQuery(string Sql, IDataParameter[] Params, object[] Values, ref ArrayList OutputValues, out string err)
  556. {
  557. err = "";
  558. DataSet ds = new DataSet();
  559. try
  560. {
  561. //给所有的参数赋值
  562. if (Params != null && Values != null)
  563. {
  564. string[] ParameterNames = new string[Params.Length];
  565. DbType[] DbTypes = new DbType[Params.Length];
  566. ParameterDirection[] Directions = new ParameterDirection[Params.Length];
  567. bool[] IsNullables = new bool[Params.Length];
  568. string[] SourceColumns = new string[Params.Length];
  569. DataRowVersion[] SourceVersions = new DataRowVersion[Params.Length];
  570. for (int i = 0; i < Params.Length; i++)
  571. {
  572. ParameterNames[i] = Params[i].ParameterName;
  573. DbTypes[i] = Params[i].DbType;
  574. Directions[i] = Params[i].Direction;
  575. IsNullables[i] = Params[i].IsNullable;
  576. SourceColumns[i] = Params[i].SourceColumn;
  577. SourceVersions[i] = Params[i].SourceVersion;
  578. }
  579. ds = _dbProxy.ExecuteQuery(_dbName, _priority, Sql, CommandType.Text, ParameterNames, DbTypes, Directions, IsNullables, SourceColumns, SourceVersions, Values, ref OutputValues, out err);
  580. }
  581. else
  582. {
  583. ds = _dbProxy.ExecuteQuery(_dbName, _priority, Sql, CommandType.Text, null, null, out err);
  584. }
  585. _errMsg = err;
  586. }
  587. catch (Exception ex)
  588. {
  589. _valid = false;
  590. err = _errMsg = ex.Message;
  591. }
  592. return ds;
  593. }
  594. //执行带参数的SQL语句,返回DataSet
  595. public DataSet ExecuteQuery(string Sql, CommandType cmdType, IDataParameter[] Params, object[] Values, Guid guid)
  596. {
  597. DataSet ds = new DataSet();
  598. ArrayList OutputValues = null;
  599. try
  600. {
  601. //给所有的参数赋值
  602. if (Params != null && Values != null)
  603. {
  604. string[] ParameterNames = new string[Params.Length];
  605. DbType[] DbTypes = new DbType[Params.Length];
  606. ParameterDirection[] Directions = new ParameterDirection[Params.Length];
  607. bool[] IsNullables = new bool[Params.Length];
  608. string[] SourceColumns = new string[Params.Length];
  609. DataRowVersion[] SourceVersions = new DataRowVersion[Params.Length];
  610. for (int i = 0; i < Params.Length; i++)
  611. {
  612. ParameterNames[i] = Params[i].ParameterName;
  613. DbTypes[i] = Params[i].DbType;
  614. Directions[i] = Params[i].Direction;
  615. IsNullables[i] = Params[i].IsNullable;
  616. SourceColumns[i] = Params[i].SourceColumn;
  617. SourceVersions[i] = Params[i].SourceVersion;
  618. }
  619. ds = _dbProxy.ExecuteQuery(_dbName, _priority, guid, Sql, cmdType, ParameterNames, DbTypes, Directions, IsNullables, SourceColumns, SourceVersions, Values, ref OutputValues, out _errMsg);
  620. }
  621. else
  622. {
  623. ds = _dbProxy.ExecuteQuery(_dbName, _priority, guid, Sql, cmdType, null, null, out _errMsg);
  624. }
  625. }
  626. catch (Exception ex)
  627. {
  628. _valid = false;
  629. _errMsg = ex.Message;
  630. }
  631. return ds;
  632. }
  633. public DataSet ExecuteQuery(string Sql, CommandType cmdType, IDataParameter[] Params, object[] Values)
  634. {
  635. DataSet ds = new DataSet();
  636. ArrayList OutputValues = null;
  637. try
  638. {
  639. //给所有的参数赋值
  640. if (Params != null && Values != null)
  641. {
  642. string[] ParameterNames = new string[Params.Length];
  643. DbType[] DbTypes = new DbType[Params.Length];
  644. ParameterDirection[] Directions = new ParameterDirection[Params.Length];
  645. bool[] IsNullables = new bool[Params.Length];
  646. string[] SourceColumns = new string[Params.Length];
  647. DataRowVersion[] SourceVersions = new DataRowVersion[Params.Length];
  648. for (int i = 0; i < Params.Length; i++)
  649. {
  650. ParameterNames[i] = Params[i].ParameterName;
  651. DbTypes[i] = Params[i].DbType;
  652. Directions[i] = Params[i].Direction;
  653. IsNullables[i] = Params[i].IsNullable;
  654. SourceColumns[i] = Params[i].SourceColumn;
  655. SourceVersions[i] = Params[i].SourceVersion;
  656. }
  657. ds = _dbProxy.ExecuteQuery(_dbName, _priority, Sql, cmdType, ParameterNames, DbTypes, Directions, IsNullables, SourceColumns, SourceVersions, Values, ref OutputValues, out _errMsg);
  658. }
  659. else
  660. {
  661. ds = _dbProxy.ExecuteQuery(_dbName, _priority, Sql, cmdType, null, null, out _errMsg);
  662. }
  663. }
  664. catch (Exception ex)
  665. {
  666. _valid = false;
  667. _errMsg = ex.Message;
  668. }
  669. return ds;
  670. }
  671. //执行带参数的SQL语句,返回DataSet
  672. public DataSet ExecuteQuery(string Sql, CommandType cmdType, IDataParameter[] Params, object[] Values, ref ArrayList OutputValues, Guid guid)
  673. {
  674. DataSet ds = new DataSet();
  675. try
  676. {
  677. //给所有的参数赋值
  678. if (Params != null && Values != null)
  679. {
  680. string[] ParameterNames = new string[Params.Length];
  681. DbType[] DbTypes = new DbType[Params.Length];
  682. ParameterDirection[] Directions = new ParameterDirection[Params.Length];
  683. bool[] IsNullables = new bool[Params.Length];
  684. string[] SourceColumns = new string[Params.Length];
  685. DataRowVersion[] SourceVersions = new DataRowVersion[Params.Length];
  686. for (int i = 0; i < Params.Length; i++)
  687. {
  688. ParameterNames[i] = Params[i].ParameterName;
  689. DbTypes[i] = Params[i].DbType;
  690. Directions[i] = Params[i].Direction;
  691. IsNullables[i] = Params[i].IsNullable;
  692. SourceColumns[i] = Params[i].SourceColumn;
  693. SourceVersions[i] = Params[i].SourceVersion;
  694. }
  695. ds = _dbProxy.ExecuteQuery(_dbName, _priority, guid, Sql, cmdType, ParameterNames, DbTypes, Directions, IsNullables, SourceColumns, SourceVersions, Values, ref OutputValues, out _errMsg);
  696. }
  697. else
  698. {
  699. ds = _dbProxy.ExecuteQuery(_dbName, _priority, guid, Sql, cmdType, null, null, out _errMsg);
  700. }
  701. }
  702. catch (Exception ex)
  703. {
  704. _valid = false;
  705. _errMsg = ex.Message;
  706. }
  707. return ds;
  708. }
  709. public DataSet ExecuteQuery(string Sql, CommandType cmdType, IDataParameter[] Params, object[] Values, ref ArrayList OutputValues)
  710. {
  711. DataSet ds = new DataSet();
  712. try
  713. {
  714. //给所有的参数赋值
  715. if (Params != null && Values != null)
  716. {
  717. string[] ParameterNames = new string[Params.Length];
  718. DbType[] DbTypes = new DbType[Params.Length];
  719. ParameterDirection[] Directions = new ParameterDirection[Params.Length];
  720. bool[] IsNullables = new bool[Params.Length];
  721. string[] SourceColumns = new string[Params.Length];
  722. DataRowVersion[] SourceVersions = new DataRowVersion[Params.Length];
  723. for (int i = 0; i < Params.Length; i++)
  724. {
  725. ParameterNames[i] = Params[i].ParameterName;
  726. DbTypes[i] = Params[i].DbType;
  727. Directions[i] = Params[i].Direction;
  728. IsNullables[i] = Params[i].IsNullable;
  729. SourceColumns[i] = Params[i].SourceColumn;
  730. SourceVersions[i] = Params[i].SourceVersion;
  731. }
  732. ds = _dbProxy.ExecuteQuery(_dbName, _priority, Sql, cmdType, ParameterNames, DbTypes, Directions, IsNullables, SourceColumns, SourceVersions, Values, ref OutputValues, out _errMsg);
  733. }
  734. else
  735. {
  736. ds = _dbProxy.ExecuteQuery(_dbName, _priority, Sql, cmdType, null, null, out _errMsg);
  737. }
  738. }
  739. catch (Exception ex)
  740. {
  741. _valid = false;
  742. _errMsg = ex.Message;
  743. }
  744. return ds;
  745. }
  746. //执行带参数的SQL语句,返回DataSet
  747. public DataSet ExecuteQuery(string Sql, CommandType cmdType, IDataParameter[] Params, object[] Values, Guid guid, out string err)
  748. {
  749. err = "";
  750. DataSet ds = new DataSet();
  751. ArrayList OutputValues = null;
  752. try
  753. {
  754. //给所有的参数赋值
  755. if (Params != null && Values != null)
  756. {
  757. string[] ParameterNames = new string[Params.Length];
  758. DbType[] DbTypes = new DbType[Params.Length];
  759. ParameterDirection[] Directions = new ParameterDirection[Params.Length];
  760. bool[] IsNullables = new bool[Params.Length];
  761. string[] SourceColumns = new string[Params.Length];
  762. DataRowVersion[] SourceVersions = new DataRowVersion[Params.Length];
  763. for (int i = 0; i < Params.Length; i++)
  764. {
  765. ParameterNames[i] = Params[i].ParameterName;
  766. DbTypes[i] = Params[i].DbType;
  767. Directions[i] = Params[i].Direction;
  768. IsNullables[i] = Params[i].IsNullable;
  769. SourceColumns[i] = Params[i].SourceColumn;
  770. SourceVersions[i] = Params[i].SourceVersion;
  771. }
  772. ds = _dbProxy.ExecuteQuery(_dbName, _priority, guid, Sql, cmdType, ParameterNames, DbTypes, Directions, IsNullables, SourceColumns, SourceVersions, Values, ref OutputValues, out err);
  773. }
  774. else
  775. {
  776. ds = _dbProxy.ExecuteQuery(_dbName, _priority, guid, Sql, cmdType, null, null, out err);
  777. }
  778. _errMsg = err;
  779. }
  780. catch (Exception ex)
  781. {
  782. _valid = false;
  783. err = _errMsg = ex.Message;
  784. }
  785. return ds;
  786. }
  787. public DataSet ExecuteQuery(string Sql, CommandType cmdType, IDataParameter[] Params, object[] Values, out string err)
  788. {
  789. err = "";
  790. DataSet ds = new DataSet();
  791. ArrayList OutputValues = null;
  792. try
  793. {
  794. //给所有的参数赋值
  795. if (Params != null && Values != null)
  796. {
  797. string[] ParameterNames = new string[Params.Length];
  798. DbType[] DbTypes = new DbType[Params.Length];
  799. ParameterDirection[] Directions = new ParameterDirection[Params.Length];
  800. bool[] IsNullables = new bool[Params.Length];
  801. string[] SourceColumns = new string[Params.Length];
  802. DataRowVersion[] SourceVersions = new DataRowVersion[Params.Length];
  803. for (int i = 0; i < Params.Length; i++)
  804. {
  805. ParameterNames[i] = Params[i].ParameterName;
  806. DbTypes[i] = Params[i].DbType;
  807. Directions[i] = Params[i].Direction;
  808. IsNullables[i] = Params[i].IsNullable;
  809. SourceColumns[i] = Params[i].SourceColumn;
  810. SourceVersions[i] = Params[i].SourceVersion;
  811. }
  812. ds = _dbProxy.ExecuteQuery(_dbName, _priority, Sql, cmdType, ParameterNames, DbTypes, Directions, IsNullables, SourceColumns, SourceVersions, Values, ref OutputValues, out err);
  813. }
  814. else
  815. {
  816. ds = _dbProxy.ExecuteQuery(_dbName, _priority, Sql, cmdType, null, null, out err);
  817. }
  818. _errMsg = err;
  819. }
  820. catch (Exception ex)
  821. {
  822. _valid = false;
  823. err = _errMsg = ex.Message;
  824. }
  825. return ds;
  826. }
  827. //执行带参数的SQL语句,返回DataSet
  828. public DataSet ExecuteQuery(string Sql, CommandType cmdType, IDataParameter[] Params, object[] Values, ref ArrayList OutputValues, Guid guid, out string err)
  829. {
  830. err = "";
  831. DataSet ds = new DataSet();
  832. try
  833. {
  834. //给所有的参数赋值
  835. if (Params != null && Values != null)
  836. {
  837. string[] ParameterNames = new string[Params.Length];
  838. DbType[] DbTypes = new DbType[Params.Length];
  839. ParameterDirection[] Directions = new ParameterDirection[Params.Length];
  840. bool[] IsNullables = new bool[Params.Length];
  841. string[] SourceColumns = new string[Params.Length];
  842. DataRowVersion[] SourceVersions = new DataRowVersion[Params.Length];
  843. for (int i = 0; i < Params.Length; i++)
  844. {
  845. ParameterNames[i] = Params[i].ParameterName;
  846. DbTypes[i] = Params[i].DbType;
  847. Directions[i] = Params[i].Direction;
  848. IsNullables[i] = Params[i].IsNullable;
  849. SourceColumns[i] = Params[i].SourceColumn;
  850. SourceVersions[i] = Params[i].SourceVersion;
  851. }
  852. ds = _dbProxy.ExecuteQuery(_dbName, _priority, guid, Sql, cmdType, ParameterNames, DbTypes, Directions, IsNullables, SourceColumns, SourceVersions, Values, ref OutputValues, out err);
  853. }
  854. else
  855. {
  856. ds = _dbProxy.ExecuteQuery(_dbName, _priority, guid, Sql, cmdType, null, null, out err);
  857. }
  858. _errMsg = err;
  859. }
  860. catch (Exception ex)
  861. {
  862. _valid = false;
  863. err = _errMsg = ex.Message;
  864. }
  865. return ds;
  866. }
  867. public DataSet ExecuteQuery(string Sql, CommandType cmdType, IDataParameter[] Params, object[] Values, ref ArrayList OutputValues, out string err)
  868. {
  869. err = "";
  870. DataSet ds = new DataSet();
  871. try
  872. {
  873. //给所有的参数赋值
  874. if (Params != null && Values != null)
  875. {
  876. string[] ParameterNames = new string[Params.Length];
  877. DbType[] DbTypes = new DbType[Params.Length];
  878. ParameterDirection[] Directions = new ParameterDirection[Params.Length];
  879. bool[] IsNullables = new bool[Params.Length];
  880. string[] SourceColumns = new string[Params.Length];
  881. DataRowVersion[] SourceVersions = new DataRowVersion[Params.Length];
  882. for (int i = 0; i < Params.Length; i++)
  883. {
  884. ParameterNames[i] = Params[i].ParameterName;
  885. DbTypes[i] = Params[i].DbType;
  886. Directions[i] = Params[i].Direction;
  887. IsNullables[i] = Params[i].IsNullable;
  888. SourceColumns[i] = Params[i].SourceColumn;
  889. SourceVersions[i] = Params[i].SourceVersion;
  890. }
  891. ds = _dbProxy.ExecuteQuery(_dbName, _priority, Sql, cmdType, ParameterNames, DbTypes, Directions, IsNullables, SourceColumns, SourceVersions, Values, ref OutputValues, out err);
  892. }
  893. else
  894. {
  895. ds = _dbProxy.ExecuteQuery(_dbName, _priority, Sql, cmdType, null, null, out err);
  896. }
  897. _errMsg = err;
  898. }
  899. catch (Exception ex)
  900. {
  901. _valid = false;
  902. err = _errMsg = ex.Message;
  903. }
  904. return ds;
  905. }
  906. //执行SQL语句,返回受影响的行数
  907. public int ExecuteNonQuery(string Sql, Guid guid)
  908. {
  909. int lines = -1;
  910. try
  911. {
  912. lines = _dbProxy.ExecuteNonQuery(_dbName, _priority, guid, Sql, CommandType.Text, null, null, out _errMsg);
  913. }
  914. catch (Exception ex)
  915. {
  916. _valid = false;
  917. _errMsg = ex.Message;
  918. }
  919. return lines;
  920. }
  921. public int ExecuteNonQuery(string Sql)
  922. {
  923. int lines = -1;
  924. try
  925. {
  926. lines = _dbProxy.ExecuteNonQuery(_dbName, _priority, Sql, CommandType.Text, null, null, out _errMsg);
  927. }
  928. catch (Exception ex)
  929. {
  930. _valid = false;
  931. _errMsg = ex.Message;
  932. }
  933. return lines;
  934. }
  935. //执行SQL语句,返回受影响的行数
  936. public int ExecuteNonQuery(string Sql, Guid guid, out string err)
  937. {
  938. err = "";
  939. int lines = -1;
  940. try
  941. {
  942. lines = _dbProxy.ExecuteNonQuery(_dbName, _priority, guid, Sql, CommandType.Text, null, null, out err);
  943. _errMsg = err;
  944. }
  945. catch (Exception ex)
  946. {
  947. _valid = false;
  948. err = _errMsg = ex.Message;
  949. }
  950. return lines;
  951. }
  952. public int ExecuteNonQuery(string Sql, out string err)
  953. {
  954. err = "";
  955. int lines = -1;
  956. try
  957. {
  958. lines = _dbProxy.ExecuteNonQuery(_dbName, _priority, Sql, CommandType.Text, null, null, out err);
  959. _errMsg = err;
  960. }
  961. catch (Exception ex)
  962. {
  963. _valid = false;
  964. err = _errMsg = ex.Message;
  965. }
  966. return lines;
  967. }
  968. //执行SQL语句,返回受影响的行数
  969. public int ExecuteNonQuery(string Sql, CommandType cmdType, Guid guid)
  970. {
  971. int lines = -1;
  972. try
  973. {
  974. lines = _dbProxy.ExecuteNonQuery(_dbName, _priority, guid, Sql, cmdType, null, null, out _errMsg);
  975. }
  976. catch (Exception ex)
  977. {
  978. _valid = false;
  979. _errMsg = ex.Message;
  980. }
  981. return lines;
  982. }
  983. public int ExecuteNonQuery(string Sql, CommandType cmdType)
  984. {
  985. int lines = -1;
  986. try
  987. {
  988. lines = _dbProxy.ExecuteNonQuery(_dbName, _priority, Sql, cmdType, null, null, out _errMsg);
  989. }
  990. catch (Exception ex)
  991. {
  992. _valid = false;
  993. _errMsg = ex.Message;
  994. }
  995. return lines;
  996. }
  997. //执行SQL语句,返回受影响的行数
  998. public int ExecuteNonQuery(string Sql, CommandType cmdType, Guid guid, out string err)
  999. {
  1000. err = "";
  1001. int lines = -1;
  1002. try
  1003. {
  1004. lines = _dbProxy.ExecuteNonQuery(_dbName, _priority, guid, Sql, cmdType, null, null, out err);
  1005. _errMsg = err;
  1006. }
  1007. catch (Exception ex)
  1008. {
  1009. _valid = false;
  1010. err = _errMsg = ex.Message;
  1011. }
  1012. return lines;
  1013. }
  1014. public int ExecuteNonQuery(string Sql, CommandType cmdType, out string err)
  1015. {
  1016. err = "";
  1017. int lines = -1;
  1018. try
  1019. {
  1020. lines = _dbProxy.ExecuteNonQuery(_dbName, _priority, Sql, cmdType, null, null, out err);
  1021. _errMsg = err;
  1022. }
  1023. catch (Exception ex)
  1024. {
  1025. _valid = false;
  1026. err = _errMsg = ex.Message;
  1027. }
  1028. return lines;
  1029. }
  1030. //执行带参数的SQL语句,返回受影响的行数
  1031. public int ExecuteNonQuery(string Sql, IDataParameter[] Params, object[] Values, Guid guid)
  1032. {
  1033. int lines = -1;
  1034. ArrayList OutputValues = null;
  1035. try
  1036. {
  1037. //给所有的参数赋值
  1038. if (Params != null && Values != null)
  1039. {
  1040. string[] ParameterNames = new string[Params.Length];
  1041. DbType[] DbTypes = new DbType[Params.Length];
  1042. ParameterDirection[] Directions = new ParameterDirection[Params.Length];
  1043. bool[] IsNullables = new bool[Params.Length];
  1044. string[] SourceColumns = new string[Params.Length];
  1045. DataRowVersion[] SourceVersions = new DataRowVersion[Params.Length];
  1046. for (int i = 0; i < Params.Length; i++)
  1047. {
  1048. ParameterNames[i] = Params[i].ParameterName;
  1049. DbTypes[i] = Params[i].DbType;
  1050. Directions[i] = Params[i].Direction;
  1051. IsNullables[i] = Params[i].IsNullable;
  1052. SourceColumns[i] = Params[i].SourceColumn;
  1053. SourceVersions[i] = Params[i].SourceVersion;
  1054. }
  1055. lines = _dbProxy.ExecuteNonQuery(_dbName, _priority, guid, Sql, CommandType.Text, ParameterNames, DbTypes, Directions, IsNullables, SourceColumns, SourceVersions, Values, ref OutputValues, out _errMsg);
  1056. }
  1057. else
  1058. {
  1059. lines = _dbProxy.ExecuteNonQuery(_dbName, _priority, guid, Sql, CommandType.Text, null, null, out _errMsg);
  1060. }
  1061. }
  1062. catch (Exception ex)
  1063. {
  1064. _valid = false;
  1065. _errMsg = ex.Message;
  1066. }
  1067. return lines;
  1068. }
  1069. public int ExecuteNonQuery(string Sql, IDataParameter[] Params, object[] Values)
  1070. {
  1071. int lines = -1;
  1072. ArrayList OutputValues = null;
  1073. try
  1074. {
  1075. //给所有的参数赋值
  1076. if (Params != null && Values != null)
  1077. {
  1078. string[] ParameterNames = new string[Params.Length];
  1079. DbType[] DbTypes = new DbType[Params.Length];
  1080. ParameterDirection[] Directions = new ParameterDirection[Params.Length];
  1081. bool[] IsNullables = new bool[Params.Length];
  1082. string[] SourceColumns = new string[Params.Length];
  1083. DataRowVersion[] SourceVersions = new DataRowVersion[Params.Length];
  1084. for (int i = 0; i < Params.Length; i++)
  1085. {
  1086. ParameterNames[i] = Params[i].ParameterName;
  1087. DbTypes[i] = Params[i].DbType;
  1088. Directions[i] = Params[i].Direction;
  1089. IsNullables[i] = Params[i].IsNullable;
  1090. SourceColumns[i] = Params[i].SourceColumn;
  1091. SourceVersions[i] = Params[i].SourceVersion;
  1092. }
  1093. lines = _dbProxy.ExecuteNonQuery(_dbName, _priority, Sql, CommandType.Text, ParameterNames, DbTypes, Directions, IsNullables, SourceColumns, SourceVersions, Values, ref OutputValues, out _errMsg);
  1094. }
  1095. else
  1096. {
  1097. lines = _dbProxy.ExecuteNonQuery(_dbName, _priority, Sql, CommandType.Text, null, null, out _errMsg);
  1098. }
  1099. }
  1100. catch (Exception ex)
  1101. {
  1102. _valid = false;
  1103. _errMsg = ex.Message;
  1104. }
  1105. return lines;
  1106. }
  1107. //执行带参数的SQL语句,返回受影响的行数
  1108. public int ExecuteNonQuery(string Sql, IDataParameter[] Params, object[] Values, ref ArrayList OutputValues, Guid guid)
  1109. {
  1110. int lines = -1;
  1111. try
  1112. {
  1113. //给所有的参数赋值
  1114. if (Params != null && Values != null)
  1115. {
  1116. string[] ParameterNames = new string[Params.Length];
  1117. DbType[] DbTypes = new DbType[Params.Length];
  1118. ParameterDirection[] Directions = new ParameterDirection[Params.Length];
  1119. bool[] IsNullables = new bool[Params.Length];
  1120. string[] SourceColumns = new string[Params.Length];
  1121. DataRowVersion[] SourceVersions = new DataRowVersion[Params.Length];
  1122. for (int i = 0; i < Params.Length; i++)
  1123. {
  1124. ParameterNames[i] = Params[i].ParameterName;
  1125. DbTypes[i] = Params[i].DbType;
  1126. Directions[i] = Params[i].Direction;
  1127. IsNullables[i] = Params[i].IsNullable;
  1128. SourceColumns[i] = Params[i].SourceColumn;
  1129. SourceVersions[i] = Params[i].SourceVersion;
  1130. }
  1131. lines = _dbProxy.ExecuteNonQuery(_dbName, _priority, guid, Sql, CommandType.Text, ParameterNames, DbTypes, Directions, IsNullables, SourceColumns, SourceVersions, Values, ref OutputValues, out _errMsg);
  1132. }
  1133. else
  1134. {
  1135. lines = _dbProxy.ExecuteNonQuery(_dbName, _priority, guid, Sql, CommandType.Text, null, null, out _errMsg);
  1136. }
  1137. }
  1138. catch (Exception ex)
  1139. {
  1140. _valid = false;
  1141. _errMsg = ex.Message;
  1142. }
  1143. return lines;
  1144. }
  1145. public int ExecuteNonQuery(string Sql, IDataParameter[] Params, object[] Values, ref ArrayList OutputValues)
  1146. {
  1147. int lines = -1;
  1148. try
  1149. {
  1150. //给所有的参数赋值
  1151. if (Params != null && Values != null)
  1152. {
  1153. string[] ParameterNames = new string[Params.Length];
  1154. DbType[] DbTypes = new DbType[Params.Length];
  1155. ParameterDirection[] Directions = new ParameterDirection[Params.Length];
  1156. bool[] IsNullables = new bool[Params.Length];
  1157. string[] SourceColumns = new string[Params.Length];
  1158. DataRowVersion[] SourceVersions = new DataRowVersion[Params.Length];
  1159. for (int i = 0; i < Params.Length; i++)
  1160. {
  1161. ParameterNames[i] = Params[i].ParameterName;
  1162. DbTypes[i] = Params[i].DbType;
  1163. Directions[i] = Params[i].Direction;
  1164. IsNullables[i] = Params[i].IsNullable;
  1165. SourceColumns[i] = Params[i].SourceColumn;
  1166. SourceVersions[i] = Params[i].SourceVersion;
  1167. }
  1168. lines = _dbProxy.ExecuteNonQuery(_dbName, _priority, Sql, CommandType.Text, ParameterNames, DbTypes, Directions, IsNullables, SourceColumns, SourceVersions, Values, ref OutputValues, out _errMsg);
  1169. }
  1170. else
  1171. {
  1172. lines = _dbProxy.ExecuteNonQuery(_dbName, _priority, Sql, CommandType.Text, null, null, out _errMsg);
  1173. }
  1174. }
  1175. catch (Exception ex)
  1176. {
  1177. _valid = false;
  1178. _errMsg = ex.Message;
  1179. }
  1180. return lines;
  1181. }
  1182. //执行带参数的SQL语句,返回受影响的行数
  1183. public int ExecuteNonQuery(string Sql, IDataParameter[] Params, object[] Values, Guid guid, out string err)
  1184. {
  1185. err = "";
  1186. int lines = -1;
  1187. ArrayList OutputValues = null;
  1188. try
  1189. {
  1190. //给所有的参数赋值
  1191. if (Params != null && Values != null)
  1192. {
  1193. string[] ParameterNames = new string[Params.Length];
  1194. DbType[] DbTypes = new DbType[Params.Length];
  1195. ParameterDirection[] Directions = new ParameterDirection[Params.Length];
  1196. bool[] IsNullables = new bool[Params.Length];
  1197. string[] SourceColumns = new string[Params.Length];
  1198. DataRowVersion[] SourceVersions = new DataRowVersion[Params.Length];
  1199. for (int i = 0; i < Params.Length; i++)
  1200. {
  1201. ParameterNames[i] = Params[i].ParameterName;
  1202. DbTypes[i] = Params[i].DbType;
  1203. Directions[i] = Params[i].Direction;
  1204. IsNullables[i] = Params[i].IsNullable;
  1205. SourceColumns[i] = Params[i].SourceColumn;
  1206. SourceVersions[i] = Params[i].SourceVersion;
  1207. }
  1208. lines = _dbProxy.ExecuteNonQuery(_dbName, _priority, guid, Sql, CommandType.Text, ParameterNames, DbTypes, Directions, IsNullables, SourceColumns, SourceVersions, Values, ref OutputValues, out err);
  1209. }
  1210. else
  1211. {
  1212. lines = _dbProxy.ExecuteNonQuery(_dbName, _priority, guid, Sql, CommandType.Text, null, null, out err);
  1213. }
  1214. _errMsg = err;
  1215. }
  1216. catch (Exception ex)
  1217. {
  1218. _valid = false;
  1219. err = _errMsg = ex.Message;
  1220. }
  1221. return lines;
  1222. }
  1223. public int ExecuteNonQuery(string Sql, IDataParameter[] Params, object[] Values, out string err)
  1224. {
  1225. err = "";
  1226. int lines = -1;
  1227. ArrayList OutputValues = null;
  1228. try
  1229. {
  1230. //给所有的参数赋值
  1231. if (Params != null && Values != null)
  1232. {
  1233. string[] ParameterNames = new string[Params.Length];
  1234. DbType[] DbTypes = new DbType[Params.Length];
  1235. ParameterDirection[] Directions = new ParameterDirection[Params.Length];
  1236. bool[] IsNullables = new bool[Params.Length];
  1237. string[] SourceColumns = new string[Params.Length];
  1238. DataRowVersion[] SourceVersions = new DataRowVersion[Params.Length];
  1239. for (int i = 0; i < Params.Length; i++)
  1240. {
  1241. ParameterNames[i] = Params[i].ParameterName;
  1242. DbTypes[i] = Params[i].DbType;
  1243. Directions[i] = Params[i].Direction;
  1244. IsNullables[i] = Params[i].IsNullable;
  1245. SourceColumns[i] = Params[i].SourceColumn;
  1246. SourceVersions[i] = Params[i].SourceVersion;
  1247. }
  1248. lines = _dbProxy.ExecuteNonQuery(_dbName, _priority, Sql, CommandType.Text, ParameterNames, DbTypes, Directions, IsNullables, SourceColumns, SourceVersions, Values, ref OutputValues, out err);
  1249. }
  1250. else
  1251. {
  1252. lines = _dbProxy.ExecuteNonQuery(_dbName, _priority, Sql, CommandType.Text, null, null, out err);
  1253. }
  1254. _errMsg = err;
  1255. }
  1256. catch (Exception ex)
  1257. {
  1258. _valid = false;
  1259. err = _errMsg = ex.Message;
  1260. }
  1261. return lines;
  1262. }
  1263. //执行带参数的SQL语句,返回受影响的行数
  1264. public int ExecuteNonQuery(string Sql, IDataParameter[] Params, object[] Values, ref ArrayList OutputValues, Guid guid, out string err)
  1265. {
  1266. err = "";
  1267. int lines = -1;
  1268. try
  1269. {
  1270. //给所有的参数赋值
  1271. if (Params != null && Values != null)
  1272. {
  1273. string[] ParameterNames = new string[Params.Length];
  1274. DbType[] DbTypes = new DbType[Params.Length];
  1275. ParameterDirection[] Directions = new ParameterDirection[Params.Length];
  1276. bool[] IsNullables = new bool[Params.Length];
  1277. string[] SourceColumns = new string[Params.Length];
  1278. DataRowVersion[] SourceVersions = new DataRowVersion[Params.Length];
  1279. for (int i = 0; i < Params.Length; i++)
  1280. {
  1281. ParameterNames[i] = Params[i].ParameterName;
  1282. DbTypes[i] = Params[i].DbType;
  1283. Directions[i] = Params[i].Direction;
  1284. IsNullables[i] = Params[i].IsNullable;
  1285. SourceColumns[i] = Params[i].SourceColumn;
  1286. SourceVersions[i] = Params[i].SourceVersion;
  1287. }
  1288. lines = _dbProxy.ExecuteNonQuery(_dbName, _priority, guid, Sql, CommandType.Text, ParameterNames, DbTypes, Directions, IsNullables, SourceColumns, SourceVersions, Values, ref OutputValues, out err);
  1289. }
  1290. else
  1291. {
  1292. lines = _dbProxy.ExecuteNonQuery(_dbName, _priority, guid, Sql, CommandType.Text, null, null, out err);
  1293. }
  1294. _errMsg = err;
  1295. }
  1296. catch (Exception ex)
  1297. {
  1298. _valid = false;
  1299. err = _errMsg = ex.Message;
  1300. }
  1301. return lines;
  1302. }
  1303. public int ExecuteNonQuery(string Sql, IDataParameter[] Params, object[] Values, ref ArrayList OutputValues, out string err)
  1304. {
  1305. err = "";
  1306. int lines = -1;
  1307. try
  1308. {
  1309. //给所有的参数赋值
  1310. if (Params != null && Values != null)
  1311. {
  1312. string[] ParameterNames = new string[Params.Length];
  1313. DbType[] DbTypes = new DbType[Params.Length];
  1314. ParameterDirection[] Directions = new ParameterDirection[Params.Length];
  1315. bool[] IsNullables = new bool[Params.Length];
  1316. string[] SourceColumns = new string[Params.Length];
  1317. DataRowVersion[] SourceVersions = new DataRowVersion[Params.Length];
  1318. for (int i = 0; i < Params.Length; i++)
  1319. {
  1320. ParameterNames[i] = Params[i].ParameterName;
  1321. DbTypes[i] = Params[i].DbType;
  1322. Directions[i] = Params[i].Direction;
  1323. IsNullables[i] = Params[i].IsNullable;
  1324. SourceColumns[i] = Params[i].SourceColumn;
  1325. SourceVersions[i] = Params[i].SourceVersion;
  1326. }
  1327. lines = _dbProxy.ExecuteNonQuery(_dbName, _priority, Sql, CommandType.Text, ParameterNames, DbTypes, Directions, IsNullables, SourceColumns, SourceVersions, Values, ref OutputValues, out err);
  1328. }
  1329. else
  1330. {
  1331. lines = _dbProxy.ExecuteNonQuery(_dbName, _priority, Sql, CommandType.Text, null, null, out err);
  1332. }
  1333. _errMsg = err;
  1334. }
  1335. catch (Exception ex)
  1336. {
  1337. _valid = false;
  1338. err = _errMsg = ex.Message;
  1339. }
  1340. return lines;
  1341. }
  1342. //执行带参数的SQL语句,返回受影响的行数
  1343. public int ExecuteNonQuery(string Sql, CommandType cmdType, IDataParameter[] Params, object[] Values, Guid guid)
  1344. {
  1345. int lines = -1;
  1346. ArrayList OutputValues = null;
  1347. try
  1348. {
  1349. //给所有的参数赋值
  1350. if (Params != null && Values != null)
  1351. {
  1352. string[] ParameterNames = new string[Params.Length];
  1353. DbType[] DbTypes = new DbType[Params.Length];
  1354. ParameterDirection[] Directions = new ParameterDirection[Params.Length];
  1355. bool[] IsNullables = new bool[Params.Length];
  1356. string[] SourceColumns = new string[Params.Length];
  1357. DataRowVersion[] SourceVersions = new DataRowVersion[Params.Length];
  1358. for (int i = 0; i < Params.Length; i++)
  1359. {
  1360. ParameterNames[i] = Params[i].ParameterName;
  1361. DbTypes[i] = Params[i].DbType;
  1362. Directions[i] = Params[i].Direction;
  1363. IsNullables[i] = Params[i].IsNullable;
  1364. SourceColumns[i] = Params[i].SourceColumn;
  1365. SourceVersions[i] = Params[i].SourceVersion;
  1366. }
  1367. lines = _dbProxy.ExecuteNonQuery(_dbName, _priority, guid, Sql, cmdType, ParameterNames, DbTypes, Directions, IsNullables, SourceColumns, SourceVersions, Values, ref OutputValues, out _errMsg);
  1368. }
  1369. else
  1370. {
  1371. lines = _dbProxy.ExecuteNonQuery(_dbName, _priority, guid, Sql, cmdType, null, null, out _errMsg);
  1372. }
  1373. }
  1374. catch (Exception ex)
  1375. {
  1376. _valid = false;
  1377. _errMsg = ex.Message;
  1378. }
  1379. return lines;
  1380. }
  1381. public int ExecuteNonQuery(string Sql, CommandType cmdType, IDataParameter[] Params, object[] Values)
  1382. {
  1383. int lines = -1;
  1384. ArrayList OutputValues = null;
  1385. try
  1386. {
  1387. //给所有的参数赋值
  1388. if (Params != null && Values != null)
  1389. {
  1390. string[] ParameterNames = new string[Params.Length];
  1391. DbType[] DbTypes = new DbType[Params.Length];
  1392. ParameterDirection[] Directions = new ParameterDirection[Params.Length];
  1393. bool[] IsNullables = new bool[Params.Length];
  1394. string[] SourceColumns = new string[Params.Length];
  1395. DataRowVersion[] SourceVersions = new DataRowVersion[Params.Length];
  1396. for (int i = 0; i < Params.Length; i++)
  1397. {
  1398. ParameterNames[i] = Params[i].ParameterName;
  1399. DbTypes[i] = Params[i].DbType;
  1400. Directions[i] = Params[i].Direction;
  1401. IsNullables[i] = Params[i].IsNullable;
  1402. SourceColumns[i] = Params[i].SourceColumn;
  1403. SourceVersions[i] = Params[i].SourceVersion;
  1404. }
  1405. lines = _dbProxy.ExecuteNonQuery(_dbName, _priority, Sql, cmdType, ParameterNames, DbTypes, Directions, IsNullables, SourceColumns, SourceVersions, Values, ref OutputValues, out _errMsg);
  1406. }
  1407. else
  1408. {
  1409. lines = _dbProxy.ExecuteNonQuery(_dbName, _priority, Sql, cmdType, null, null, out _errMsg);
  1410. }
  1411. }
  1412. catch (Exception ex)
  1413. {
  1414. _valid = false;
  1415. _errMsg = ex.Message;
  1416. }
  1417. return lines;
  1418. }
  1419. //执行带参数的SQL语句,返回受影响的行数
  1420. public int ExecuteNonQuery(string Sql, CommandType cmdType, IDataParameter[] Params, object[] Values, ref ArrayList OutputValues, Guid guid)
  1421. {
  1422. int lines = -1;
  1423. try
  1424. {
  1425. //给所有的参数赋值
  1426. if (Params != null && Values != null)
  1427. {
  1428. string[] ParameterNames = new string[Params.Length];
  1429. DbType[] DbTypes = new DbType[Params.Length];
  1430. ParameterDirection[] Directions = new ParameterDirection[Params.Length];
  1431. bool[] IsNullables = new bool[Params.Length];
  1432. string[] SourceColumns = new string[Params.Length];
  1433. DataRowVersion[] SourceVersions = new DataRowVersion[Params.Length];
  1434. for (int i = 0; i < Params.Length; i++)
  1435. {
  1436. ParameterNames[i] = Params[i].ParameterName;
  1437. DbTypes[i] = Params[i].DbType;
  1438. Directions[i] = Params[i].Direction;
  1439. IsNullables[i] = Params[i].IsNullable;
  1440. SourceColumns[i] = Params[i].SourceColumn;
  1441. SourceVersions[i] = Params[i].SourceVersion;
  1442. }
  1443. lines = _dbProxy.ExecuteNonQuery(_dbName, _priority, guid, Sql, cmdType, ParameterNames, DbTypes, Directions, IsNullables, SourceColumns, SourceVersions, Values, ref OutputValues, out _errMsg);
  1444. }
  1445. else
  1446. {
  1447. lines = _dbProxy.ExecuteNonQuery(_dbName, _priority, guid, Sql, cmdType, null, null, out _errMsg);
  1448. }
  1449. }
  1450. catch (Exception ex)
  1451. {
  1452. _valid = false;
  1453. _errMsg = ex.Message;
  1454. }
  1455. return lines;
  1456. }
  1457. public int ExecuteNonQuery(string Sql, CommandType cmdType, IDataParameter[] Params, object[] Values, ref ArrayList OutputValues)
  1458. {
  1459. int lines = -1;
  1460. try
  1461. {
  1462. //给所有的参数赋值
  1463. if (Params != null && Values != null)
  1464. {
  1465. string[] ParameterNames = new string[Params.Length];
  1466. DbType[] DbTypes = new DbType[Params.Length];
  1467. ParameterDirection[] Directions = new ParameterDirection[Params.Length];
  1468. bool[] IsNullables = new bool[Params.Length];
  1469. string[] SourceColumns = new string[Params.Length];
  1470. DataRowVersion[] SourceVersions = new DataRowVersion[Params.Length];
  1471. for (int i = 0; i < Params.Length; i++)
  1472. {
  1473. ParameterNames[i] = Params[i].ParameterName;
  1474. DbTypes[i] = Params[i].DbType;
  1475. Directions[i] = Params[i].Direction;
  1476. IsNullables[i] = Params[i].IsNullable;
  1477. SourceColumns[i] = Params[i].SourceColumn;
  1478. SourceVersions[i] = Params[i].SourceVersion;
  1479. }
  1480. lines = _dbProxy.ExecuteNonQuery(_dbName, _priority, Sql, cmdType, ParameterNames, DbTypes, Directions, IsNullables, SourceColumns, SourceVersions, Values, ref OutputValues, out _errMsg);
  1481. }
  1482. else
  1483. {
  1484. lines = _dbProxy.ExecuteNonQuery(_dbName, _priority, Sql, cmdType, null, null, out _errMsg);
  1485. }
  1486. }
  1487. catch (Exception ex)
  1488. {
  1489. _valid = false;
  1490. _errMsg = ex.Message;
  1491. }
  1492. return lines;
  1493. }
  1494. //执行带参数的SQL语句,返回受影响的行数
  1495. public int ExecuteNonQuery(string Sql, CommandType cmdType, IDataParameter[] Params, object[] Values, Guid guid, out string err)
  1496. {
  1497. err = "";
  1498. int lines = -1;
  1499. ArrayList OutputValues = null;
  1500. try
  1501. {
  1502. //给所有的参数赋值
  1503. if (Params != null && Values != null)
  1504. {
  1505. string[] ParameterNames = new string[Params.Length];
  1506. DbType[] DbTypes = new DbType[Params.Length];
  1507. ParameterDirection[] Directions = new ParameterDirection[Params.Length];
  1508. bool[] IsNullables = new bool[Params.Length];
  1509. string[] SourceColumns = new string[Params.Length];
  1510. DataRowVersion[] SourceVersions = new DataRowVersion[Params.Length];
  1511. for (int i = 0; i < Params.Length; i++)
  1512. {
  1513. ParameterNames[i] = Params[i].ParameterName;
  1514. DbTypes[i] = Params[i].DbType;
  1515. Directions[i] = Params[i].Direction;
  1516. IsNullables[i] = Params[i].IsNullable;
  1517. SourceColumns[i] = Params[i].SourceColumn;
  1518. SourceVersions[i] = Params[i].SourceVersion;
  1519. }
  1520. lines = _dbProxy.ExecuteNonQuery(_dbName, _priority, guid, Sql, cmdType, ParameterNames, DbTypes, Directions, IsNullables, SourceColumns, SourceVersions, Values, ref OutputValues, out err);
  1521. }
  1522. else
  1523. {
  1524. lines = _dbProxy.ExecuteNonQuery(_dbName, _priority, guid, Sql, cmdType, null, null, out err);
  1525. }
  1526. _errMsg = err;
  1527. }
  1528. catch (Exception ex)
  1529. {
  1530. _valid = false;
  1531. err = _errMsg = ex.Message;
  1532. }
  1533. return lines;
  1534. }
  1535. public int ExecuteNonQuery(string Sql, CommandType cmdType, IDataParameter[] Params, object[] Values, out string err)
  1536. {
  1537. err = "";
  1538. int lines = -1;
  1539. ArrayList OutputValues = null;
  1540. try
  1541. {
  1542. //给所有的参数赋值
  1543. if (Params != null && Values != null)
  1544. {
  1545. string[] ParameterNames = new string[Params.Length];
  1546. DbType[] DbTypes = new DbType[Params.Length];
  1547. ParameterDirection[] Directions = new ParameterDirection[Params.Length];
  1548. bool[] IsNullables = new bool[Params.Length];
  1549. string[] SourceColumns = new string[Params.Length];
  1550. DataRowVersion[] SourceVersions = new DataRowVersion[Params.Length];
  1551. for (int i = 0; i < Params.Length; i++)
  1552. {
  1553. ParameterNames[i] = Params[i].ParameterName;
  1554. DbTypes[i] = Params[i].DbType;
  1555. Directions[i] = Params[i].Direction;
  1556. IsNullables[i] = Params[i].IsNullable;
  1557. SourceColumns[i] = Params[i].SourceColumn;
  1558. SourceVersions[i] = Params[i].SourceVersion;
  1559. }
  1560. lines = _dbProxy.ExecuteNonQuery(_dbName, _priority, Sql, cmdType, ParameterNames, DbTypes, Directions, IsNullables, SourceColumns, SourceVersions, Values, ref OutputValues, out err);
  1561. }
  1562. else
  1563. {
  1564. lines = _dbProxy.ExecuteNonQuery(_dbName, _priority, Sql, cmdType, null, null, out err);
  1565. }
  1566. _errMsg = err;
  1567. }
  1568. catch (Exception ex)
  1569. {
  1570. _valid = false;
  1571. err = _errMsg = ex.Message;
  1572. }
  1573. return lines;
  1574. }
  1575. //执行带参数的SQL语句,返回受影响的行数
  1576. public int ExecuteNonQuery(string Sql, CommandType cmdType, IDataParameter[] Params, object[] Values, ref ArrayList OutputValues, Guid guid, out string err)
  1577. {
  1578. err = "";
  1579. int lines = -1;
  1580. try
  1581. {
  1582. //给所有的参数赋值
  1583. if (Params != null && Values != null)
  1584. {
  1585. string[] ParameterNames = new string[Params.Length];
  1586. DbType[] DbTypes = new DbType[Params.Length];
  1587. ParameterDirection[] Directions = new ParameterDirection[Params.Length];
  1588. bool[] IsNullables = new bool[Params.Length];
  1589. string[] SourceColumns = new string[Params.Length];
  1590. DataRowVersion[] SourceVersions = new DataRowVersion[Params.Length];
  1591. int[] Sizes = new int[Params.Length];
  1592. for (int i = 0; i < Params.Length; i++)
  1593. {
  1594. ParameterNames[i] = Params[i].ParameterName;
  1595. if (this.GetDbType().ToUpper() == "ORACLE")
  1596. DbTypes[i] = (DbType)(((OracleParameter)Params[i]).OracleType);
  1597. else
  1598. DbTypes[i] = Params[i].DbType;
  1599. Directions[i] = Params[i].Direction;
  1600. IsNullables[i] = Params[i].IsNullable;
  1601. SourceColumns[i] = Params[i].SourceColumn;
  1602. SourceVersions[i] = Params[i].SourceVersion;
  1603. if (this.GetDbType().ToUpper() == "ORACLE") Sizes[i] = ((OracleParameter)Params[i]).Size;
  1604. }
  1605. if (this.GetDbType().ToUpper() == "ORACLE")
  1606. lines = _dbProxy.ExecuteNonQuery(_dbName, _priority, guid, Sql, cmdType, ParameterNames, DbTypes, Directions, IsNullables, SourceColumns, SourceVersions, Sizes, Values, ref OutputValues, out err);
  1607. else
  1608. lines = _dbProxy.ExecuteNonQuery(_dbName, _priority, guid, Sql, cmdType, ParameterNames, DbTypes, Directions, IsNullables, SourceColumns, SourceVersions, Values, ref OutputValues, out err);
  1609. }
  1610. else
  1611. {
  1612. lines = _dbProxy.ExecuteNonQuery(_dbName, _priority, guid, Sql, cmdType, null, null, out err);
  1613. }
  1614. _errMsg = err;
  1615. }
  1616. catch (Exception ex)
  1617. {
  1618. _valid = false;
  1619. err = _errMsg = ex.Message;
  1620. }
  1621. return lines;
  1622. }
  1623. public int ExecuteNonQuery(string Sql, CommandType cmdType, IDataParameter[] Params, object[] Values, ref ArrayList OutputValues, out string err)
  1624. {
  1625. err = "";
  1626. int lines = -1;
  1627. try
  1628. {
  1629. //给所有的参数赋值
  1630. if (Params != null && Values != null)
  1631. {
  1632. string[] ParameterNames = new string[Params.Length];
  1633. DbType[] DbTypes = new DbType[Params.Length];
  1634. ParameterDirection[] Directions = new ParameterDirection[Params.Length];
  1635. bool[] IsNullables = new bool[Params.Length];
  1636. string[] SourceColumns = new string[Params.Length];
  1637. DataRowVersion[] SourceVersions = new DataRowVersion[Params.Length];
  1638. int[] Sizes = new int[Params.Length];
  1639. for (int i = 0; i < Params.Length; i++)
  1640. {
  1641. ParameterNames[i] = Params[i].ParameterName;
  1642. if (this.GetDbType().ToUpper() == "ORACLE")
  1643. DbTypes[i] = (DbType)(((OracleParameter)Params[i]).OracleType);
  1644. else
  1645. DbTypes[i] = Params[i].DbType;
  1646. Directions[i] = Params[i].Direction;
  1647. IsNullables[i] = Params[i].IsNullable;
  1648. SourceColumns[i] = Params[i].SourceColumn;
  1649. SourceVersions[i] = Params[i].SourceVersion;
  1650. if (this.GetDbType().ToUpper() == "ORACLE") Sizes[i] = ((OracleParameter)Params[i]).Size;
  1651. }
  1652. if (this.GetDbType().ToUpper() == "ORACLE")
  1653. lines = _dbProxy.ExecuteNonQuery(_dbName, _priority, Sql, cmdType, ParameterNames, DbTypes, Directions, IsNullables, SourceColumns, SourceVersions, Sizes, Values, ref OutputValues, out err);
  1654. else
  1655. lines = _dbProxy.ExecuteNonQuery(_dbName, _priority, Sql, cmdType, ParameterNames, DbTypes, Directions, IsNullables, SourceColumns, SourceVersions, Values, ref OutputValues, out err);
  1656. }
  1657. else
  1658. {
  1659. lines = _dbProxy.ExecuteNonQuery(_dbName, _priority, Sql, cmdType, null, null, out err);
  1660. }
  1661. _errMsg = err;
  1662. }
  1663. catch (Exception ex)
  1664. {
  1665. _valid = false;
  1666. err = _errMsg = ex.Message;
  1667. }
  1668. return lines;
  1669. }
  1670. //不通过DBServer时使用
  1671. public int ExecuteNonQuery_NoDBSever(string Sql, CommandType cmdType, IDataParameter[] Params, Guid guid, out string err)
  1672. {
  1673. err = "";
  1674. int lines = -1;
  1675. try
  1676. {
  1677. lines = _dbProxy.ExecuteNonQuery_NoDBSever(_dbName, _priority, guid, Sql, cmdType, Params, out err);
  1678. _errMsg = err;
  1679. }
  1680. catch (Exception ex)
  1681. {
  1682. _valid = false;
  1683. err = _errMsg = ex.Message;
  1684. }
  1685. return lines;
  1686. }
  1687. public int ExecuteNonQuery_NoDBSever(string Sql, CommandType cmdType, IDataParameter[] Params, out string err)
  1688. {
  1689. err = "";
  1690. int lines = -1;
  1691. try
  1692. {
  1693. lines = _dbProxy.ExecuteNonQuery_NoDBSever(_dbName, _priority, Sql, cmdType, Params, out err);
  1694. _errMsg = err;
  1695. }
  1696. catch (Exception ex)
  1697. {
  1698. _valid = false;
  1699. err = _errMsg = ex.Message;
  1700. }
  1701. return lines;
  1702. }
  1703. //更新
  1704. public bool UpdateTable(DataTable dt, string Sql, Guid guid)
  1705. {
  1706. bool result = false;
  1707. try
  1708. {
  1709. result = _dbProxy.UpdateTable(_dbName, _priority, guid, Sql, CommandType.Text, null, null, dt, out _errMsg);
  1710. }
  1711. catch (Exception ex)
  1712. {
  1713. _valid = false;
  1714. _errMsg = ex.Message;
  1715. }
  1716. return result;
  1717. }
  1718. public bool UpdateTable(DataTable dt, string Sql)
  1719. {
  1720. bool result = false;
  1721. try
  1722. {
  1723. result = _dbProxy.UpdateTable(_dbName, _priority, Sql, CommandType.Text, null, null, dt, out _errMsg);
  1724. }
  1725. catch (Exception ex)
  1726. {
  1727. _valid = false;
  1728. _errMsg = ex.Message;
  1729. }
  1730. return result;
  1731. }
  1732. public bool UpdateTable(DataTable dt, string Sql, Guid guid, out string err)
  1733. {
  1734. err = "";
  1735. bool result = false;
  1736. try
  1737. {
  1738. result = _dbProxy.UpdateTable(_dbName, _priority, guid, Sql, CommandType.Text, null, null, dt, out err);
  1739. _errMsg = err;
  1740. }
  1741. catch (Exception ex)
  1742. {
  1743. _valid = false;
  1744. err = _errMsg = ex.Message;
  1745. }
  1746. return result;
  1747. }
  1748. public bool UpdateTable(DataTable dt, string Sql, out string err)
  1749. {
  1750. err = "";
  1751. bool result = false;
  1752. try
  1753. {
  1754. result = _dbProxy.UpdateTable(_dbName, _priority, Sql, CommandType.Text, null, null, dt, out err);
  1755. _errMsg = err;
  1756. }
  1757. catch (Exception ex)
  1758. {
  1759. _valid = false;
  1760. err = _errMsg = ex.Message;
  1761. }
  1762. return result;
  1763. }
  1764. public bool UpdateTable(DataTable dt, string Sql, IDataParameter[] Params, object[] Values, Guid guid)
  1765. {
  1766. bool result = false;
  1767. try
  1768. {
  1769. //给所有的参数赋值
  1770. if (Params != null && Values != null)
  1771. {
  1772. string[] ParameterNames = new string[Params.Length];
  1773. DbType[] DbTypes = new DbType[Params.Length];
  1774. for (int i = 0; i < Params.Length; i++)
  1775. {
  1776. ParameterNames[i] = Params[i].ParameterName;
  1777. DbTypes[i] = Params[i].DbType;
  1778. }
  1779. result = _dbProxy.UpdateTable(_dbName, _priority, guid, Sql, CommandType.Text, ParameterNames, DbTypes, Values, dt, out _errMsg);
  1780. }
  1781. else
  1782. {
  1783. result = _dbProxy.UpdateTable(_dbName, _priority, guid, Sql, CommandType.Text, null, null, null, dt, out _errMsg);
  1784. }
  1785. }
  1786. catch (Exception ex)
  1787. {
  1788. _valid = false;
  1789. _errMsg = ex.Message;
  1790. }
  1791. return result;
  1792. }
  1793. public bool UpdateTable(DataTable dt, string Sql, IDataParameter[] Params, object[] Values)
  1794. {
  1795. bool result = false;
  1796. try
  1797. {
  1798. //给所有的参数赋值
  1799. if (Params != null && Values != null)
  1800. {
  1801. string[] ParameterNames = new string[Params.Length];
  1802. DbType[] DbTypes = new DbType[Params.Length];
  1803. for (int i = 0; i < Params.Length; i++)
  1804. {
  1805. ParameterNames[i] = Params[i].ParameterName;
  1806. DbTypes[i] = Params[i].DbType;
  1807. }
  1808. result = _dbProxy.UpdateTable(_dbName, _priority, Sql, CommandType.Text, ParameterNames, DbTypes, Values, dt, out _errMsg);
  1809. }
  1810. else
  1811. {
  1812. result = _dbProxy.UpdateTable(_dbName, _priority, Sql, CommandType.Text, null, null, null, dt, out _errMsg);
  1813. }
  1814. }
  1815. catch (Exception ex)
  1816. {
  1817. _valid = false;
  1818. _errMsg = ex.Message;
  1819. }
  1820. return result;
  1821. }
  1822. public bool UpdateTable(DataTable dt, string Sql, IDataParameter[] Params, object[] Values, Guid guid, out string err)
  1823. {
  1824. bool result = false;
  1825. err = "";
  1826. try
  1827. {
  1828. //给所有的参数赋值
  1829. if (Params != null && Values != null)
  1830. {
  1831. string[] ParameterNames = new string[Params.Length];
  1832. DbType[] DbTypes = new DbType[Params.Length];
  1833. for (int i = 0; i < Params.Length; i++)
  1834. {
  1835. ParameterNames[i] = Params[i].ParameterName;
  1836. DbTypes[i] = Params[i].DbType;
  1837. }
  1838. result = _dbProxy.UpdateTable(_dbName, _priority, guid, Sql, CommandType.Text, ParameterNames, DbTypes, Values, dt, out err);
  1839. }
  1840. else
  1841. {
  1842. result = _dbProxy.UpdateTable(_dbName, _priority, guid, Sql, CommandType.Text, null, null, null, dt, out err);
  1843. }
  1844. _errMsg = err;
  1845. }
  1846. catch (Exception ex)
  1847. {
  1848. _valid = false;
  1849. _errMsg = err = ex.Message;
  1850. }
  1851. return result;
  1852. }
  1853. public bool UpdateTable(DataTable dt, string Sql, IDataParameter[] Params, object[] Values, out string err)
  1854. {
  1855. bool result = false;
  1856. err = "";
  1857. try
  1858. {
  1859. //给所有的参数赋值
  1860. if (Params != null && Values != null)
  1861. {
  1862. string[] ParameterNames = new string[Params.Length];
  1863. DbType[] DbTypes = new DbType[Params.Length];
  1864. for (int i = 0; i < Params.Length; i++)
  1865. {
  1866. ParameterNames[i] = Params[i].ParameterName;
  1867. DbTypes[i] = Params[i].DbType;
  1868. }
  1869. result = _dbProxy.UpdateTable(_dbName, _priority, Sql, CommandType.Text, ParameterNames, DbTypes, Values, dt, out err);
  1870. }
  1871. else
  1872. {
  1873. result = _dbProxy.UpdateTable(_dbName, _priority, Sql, CommandType.Text, null, null, null, dt, out err);
  1874. }
  1875. _errMsg = err;
  1876. }
  1877. catch (Exception ex)
  1878. {
  1879. _valid = false;
  1880. _errMsg = err = ex.Message;
  1881. }
  1882. return result;
  1883. }
  1884. public Guid BeginTransaction(out string err)
  1885. {
  1886. return BeginTransaction("", out err);
  1887. }
  1888. //开始处理事物,返回结果表示是否成功
  1889. public Guid BeginTransaction(string methodName, out string err)
  1890. {
  1891. err = "";
  1892. Guid guid = Guid.NewGuid();
  1893. try
  1894. {
  1895. guid = _dbProxy.BeginTransaction(methodName, _dbName, _priority, _dbManagerID, 20.00, out err);
  1896. _errMsg = err;
  1897. }
  1898. catch (Exception ex)
  1899. {
  1900. _valid = false;
  1901. err = _errMsg = ex.Message;
  1902. }
  1903. return guid;
  1904. }
  1905. public Guid BeginTransaction(double minutes, out string err)
  1906. {
  1907. return BeginTransaction("", minutes, out err);
  1908. }
  1909. //开始处理事物,指定事务最长执行时间, 返回结果表示是否成功
  1910. public Guid BeginTransaction(string methodName, double minutes, out string err)
  1911. {
  1912. err = "";
  1913. Guid guid = Guid.NewGuid();
  1914. try
  1915. {
  1916. guid = _dbProxy.BeginTransaction(methodName, _dbName, _priority, _dbManagerID, minutes, out err);
  1917. _errMsg = err;
  1918. }
  1919. catch (Exception ex)
  1920. {
  1921. _valid = false;
  1922. err = _errMsg = ex.Message;
  1923. }
  1924. return guid;
  1925. }
  1926. //提交当前事物,返回结果表示是否成功
  1927. public bool Commit(Guid guid)
  1928. {
  1929. bool bSuccess = false;
  1930. try
  1931. {
  1932. bSuccess = _dbProxy.Commit(_dbName, _priority, guid, out _errMsg);
  1933. }
  1934. catch (Exception ex)
  1935. {
  1936. _valid = false;
  1937. _errMsg = ex.Message;
  1938. }
  1939. return bSuccess;
  1940. }
  1941. //提交当前事物,返回结果表示是否成功
  1942. public bool Commit(Guid guid, out string err)
  1943. {
  1944. err = "";
  1945. bool bSuccess = false;
  1946. try
  1947. {
  1948. bSuccess = _dbProxy.Commit(_dbName, _priority, guid, out err);
  1949. _errMsg = err;
  1950. }
  1951. catch (Exception ex)
  1952. {
  1953. _valid = false;
  1954. err = _errMsg = ex.Message;
  1955. }
  1956. return bSuccess;
  1957. }
  1958. //回滚当前事务
  1959. public bool Rollback(Guid guid)
  1960. {
  1961. bool bSuccess = false;
  1962. try
  1963. {
  1964. bSuccess = _dbProxy.Rollback(_dbName, _priority, guid, out _errMsg);
  1965. }
  1966. catch (Exception ex)
  1967. {
  1968. _valid = false;
  1969. _errMsg = ex.Message;
  1970. }
  1971. return bSuccess;
  1972. }
  1973. //回滚当前事务
  1974. public bool Rollback(Guid guid, out string err)
  1975. {
  1976. err = "";
  1977. bool bSuccess = false;
  1978. try
  1979. {
  1980. bSuccess = _dbProxy.Rollback(_dbName, _priority, guid, out err);
  1981. _errMsg = err;
  1982. }
  1983. catch (Exception ex)
  1984. {
  1985. _valid = false;
  1986. err = _errMsg = ex.Message;
  1987. }
  1988. return bSuccess;
  1989. }
  1990. ////////////////////////////////////////////////////////////////////////////////////
  1991. ///私有函数
  1992. ///////////////////////////////////////////////////////////////////////////////////
  1993. ////初始化DBManager
  1994. //private void InitDBManager(string name, string priority)
  1995. //{
  1996. // //保存数据库信息
  1997. // _dbName = name;
  1998. // _priority = priority;
  1999. // _errMsg = "";
  2000. // _valid = true;
  2001. // //如果是第一次创建DBManager对象,则需先读取远程处理配置文件
  2002. // if (_firstCreate)
  2003. // {
  2004. // try
  2005. // {
  2006. // //读取远程处理配置文件clientConfig.cfg
  2007. // //RemotingConfiguration.Configure("clientConfig.cfg");
  2008. // //生成DBProxy对象
  2009. // _dbProxy = new DBProxy();
  2010. // _firstCreate = false;
  2011. // }
  2012. // catch (Exception ex)
  2013. // {
  2014. // _errMsg = ex.Message;
  2015. // _valid = false;
  2016. // throw ex;
  2017. // }
  2018. // }
  2019. // try
  2020. // {
  2021. // //获取由DBProxy为DBManager对象分配的ID
  2022. // _dbManagerID = _dbProxy.GetDBManagerID();
  2023. // //设置数据库信息
  2024. // _dbProxy.SetDbInfo(_dbManagerID, _dbName, _priority);
  2025. // }
  2026. // catch (Exception ex)
  2027. // {
  2028. // _errMsg = ex.Message;
  2029. // _valid = false;
  2030. // }
  2031. //}
  2032. //初始化DBManager
  2033. private void InitDBManager(string name)
  2034. {
  2035. //保存数据库信息
  2036. _dbName = name;
  2037. _errMsg = "";
  2038. _valid = true;
  2039. //如果是第一次创建DBManager对象,则需先读取远程处理配置文件
  2040. if (_firstCreate)
  2041. {
  2042. try
  2043. {
  2044. //读取远程处理配置文件clientConfig.cfg
  2045. //RemotingConfiguration.Configure("clientConfig.cfg");
  2046. //生成DBProxy对象
  2047. _dbProxy = new DBProxy();
  2048. _firstCreate = false;
  2049. }
  2050. catch (Exception ex)
  2051. {
  2052. _errMsg = ex.Message;
  2053. _valid = false;
  2054. throw ex;
  2055. }
  2056. }
  2057. try
  2058. {
  2059. //获取由DBProxy为DBManager对象分配的ID
  2060. _dbManagerID = _dbProxy.GetDBManagerID();
  2061. }
  2062. catch (Exception ex)
  2063. {
  2064. _errMsg = ex.Message;
  2065. _valid = false;
  2066. }
  2067. }
  2068. //////////////////////////////////////////////////////////////////////////////////
  2069. ///私有数据成员
  2070. //////////////////////////////////////////////////////////////////////////////////
  2071. public static DBProxy _dbProxy;
  2072. private long _dbManagerID;//DBProxy为DBManager对象分配的ID
  2073. private string _dbName;//数据库名称
  2074. private string _priority;//数据库访问优先级
  2075. private string _errMsg;//最后一个错误信息
  2076. private bool _valid;//DBManager有效标志,每次调用DBProxy函数时设置
  2077. private static bool _firstCreate = true;
  2078. //////////////////////////////////////////////////////////////////////////////////
  2079. ///公共属性
  2080. //////////////////////////////////////////////////////////////////////////////////
  2081. //数据库名称
  2082. public string DBName
  2083. {
  2084. get
  2085. {
  2086. return _dbName;
  2087. }
  2088. set
  2089. {
  2090. _dbName = value;
  2091. }
  2092. }
  2093. //数据库访问优先级
  2094. public string Priority
  2095. {
  2096. get
  2097. {
  2098. return _priority;
  2099. }
  2100. set
  2101. {
  2102. _priority = value;
  2103. }
  2104. }
  2105. }
  2106. }