DBManager.cs 87 KB

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