private bool getConnectionString() { XmlDocument xmlDoc = CGetSetConnectString.getConnectString("Connection.xml"); XmlElement xmlEle = xmlDoc.DocumentElement; try { if (xmlEle.SelectSingleNode("authorities").InnerText == "true") { m_connecstring = "Data Source=" + xmlEle.SelectSingleNode("servname").InnerText + ";Initial Catalog=" + xmlEle.SelectSingleNode("database").InnerText + ";Integrated Security=True;"; } else { m_connecstring = "Data Source=" + xmlEle.SelectSingleNode("servname").InnerText + ";Initial Catalog=" + xmlEle.SelectSingleNode("database").InnerText + ";User Id=" + xmlEle.SelectSingleNode("username").InnerText + ";Password="******"password").InnerText + ";"; } return(true); } catch { return(false); //XtraCustomMessageBox.Show("Lỗi kết nối đến cơ sở dữ liệu ! Xin vui lòng thiết lập lại kết nối...","Thông báo","Vâng"); } }
private bool getConnectionString() { XmlDocument xmlDoc = CGetSetConnectString.getConnectString("Connection.xml"); XmlElement xmlEle = xmlDoc.DocumentElement; try { CDatabase.m_DatabaseName = xmlEle.SelectSingleNode("database").InnerText; CDatabase.m_ServerName = xmlEle.SelectSingleNode("servname").InnerText; if (xmlEle.SelectSingleNode("authorities").InnerText == "true") { m_connecstring = "Data Source=" + xmlEle.SelectSingleNode("servname").InnerText + ";Initial Catalog=" + xmlEle.SelectSingleNode("database").InnerText + ";Integrated Security=True;"; } else { m_connecstring = "Data Source=" + xmlEle.SelectSingleNode("servname").InnerText + ";Initial Catalog=" + xmlEle.SelectSingleNode("database").InnerText + ";User Id=" + xmlEle.SelectSingleNode("username").InnerText + ";Password="******"password").InnerText + ";"; } return(true); } catch { return(false); } }