27c6cf34b70ac85ca7b6ba09451cb335d97f7a5b.svn-base 88 KB

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