public static string UseXml() { XMLHealper opXML = new XMLHealper("Data.xml"); string conn, datasource, database, userid, password; datasource = opXML.PathGetNodeValue("system/datasource"); database = opXML.PathGetNodeValue("system/database"); userid = opXML.PathGetNodeValue("system/userid"); password = opXML.PathGetNodeValue("system/password"); conn = "data source=" + datasource + ";database =" + database + "; user id =" + userid + "; password =" + password; return(conn.Trim()); }
private void FrmLink_Load(object sender, EventArgs e) { try { MessageBox.Show("数据库连接出错!请核查"); XMLHealper opxml = new XMLHealper("Data.xml"); txtServer.Text = opxml.PathGetNodeValue("system/datasource"); txtDB.Text = opxml.PathGetNodeValue("system/database"); txtUser.Text = opxml.PathGetNodeValue("system/userid"); txtPsword.Text = opxml.PathGetNodeValue("system/password"); this.AcceptButton = btnConn; this.CancelButton = btnExit; } catch { } }