/// <summary>获取连接字符串 </summary> private void SetConnectionStr(SqlConnection connection) { XMLOperation xmldoc = new XMLOperation(SysConstManage.DBInfoFilePath); string service = xmldoc.NodeRead("/INFO/SERVICE").InnerText.Trim(); string database = xmldoc.NodeRead("/INFO/DATABASE").InnerText.Trim(); string uid = xmldoc.NodeRead("/INFO/DBACCOUNT").InnerText.Trim(); string pwd = xmldoc.NodeRead("/INFO/PASSWORD").InnerText.Trim(); connection.ConnectionString = string.Format("server={0};database={1};uid={2};password={3}", service, database, uid, pwd); }
private static bool DoIsExistIdEx(object dsNmOrId, Mode mode) { XMLOperation xmlOperation = new XMLOperation(SysConstManage.DSListFile); ILibXMLNodeRead noderead = xmlOperation.NodeRead("/DSList/DSInfoCollection/DSInfo"); while (!noderead.EOF) { if (mode == Mode.ByDSID) { int id = LibSysUtils.ToInt32(noderead.Attributions["DSID"].ToString()); if (id == LibSysUtils.ToInt32(dsNmOrId)) { return(true); } } else if (mode == Mode.ByDSName) { string dsName = noderead.InnerText.Trim(); if (string.Compare(dsNmOrId.ToString(), dsName, true) == 0) { return(true); } } noderead.ReadNext(); } return(false); }
private static DataSource DoGetDataSourceEx(object dsNmOrId, Mode mode) { DataSource datasource = null; XMLOperation xmlOperation = new XMLOperation(SysConstManage.DSListFile); ILibXMLNodeRead noderead = xmlOperation.NodeRead("/DSList/DSInfoCollection/DSInfo"); string dsname = null; string package = null; while (!noderead.EOF) { if (mode == Mode.ByDSID) { int id = LibSysUtils.ToInt32(noderead.Attributions["DSID"].ToString()); if (LibSysUtils.ToInt32(dsNmOrId) == id) { dsname = noderead.Attributions["Name"].ToString(); package = noderead.Attributions["PACKAGE"].ToString(); break; } } else if (mode == Mode.ByDSName) { dsname = noderead.Attributions["Name"].ToString(); if (string.Compare(dsname, dsNmOrId.ToString(), true) == 0) { package = noderead.Attributions["PACKAGE"].ToString().Trim(); break; } } noderead.ReadNext(); } InstanceDataSource(ref datasource, dsname, package); return(datasource); }