//得到連接字符串
private string ConnectString()
{
string ConnectString = "";
XmlDocument xmlDocument = new XmlDocument();
FileStream fileStream = new FileStream(System.IO.Path.GetFullPath("../../../components/Connection.xml"),FileMode.Open);
xmlDocument.PreserveWhitespace = false;
xmlDocument.Load(fileStream);
XmlElement xmlElement = (XmlElement)xmlDocument.DocumentElement.ChildNodes[0];
ConnectString += "Data Source = "+xmlElement.ChildNodes[0].Value +";";
ConnectString += "User Id = "+xmlDocument.DocumentElement.ChildNodes[1].ChildNodes[0].Value +";";
ConnectString += "Pwd = "+xmlDocument.GetElementsByTagName("PassWord")[0].InnerText +";";
ConnectString += "DataBase  = "+xmlDocument.DocumentElement.ChildNodes[3].ChildNodes[0].Value  +";";
return ConnectString;
}Connection.xml<?xml version="1.0" encoding="utf-8" ?> 
<Conntection>
<DataSource>192.168.0.3</DataSource>
<UserId>sa</UserId>
<PassWord></PassWord>
<DataBase>SunYatSite</DataBase>
</Conntection>