d88eff1c0523857540c971b1e49003a8db994f66.svn-base 89 KB

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