Hi I have connectionstring.xml which store in my localuserAppdataPath it stored a connection from my Database i would like to read it to a class dynamically so that i can call or load it anywhere in other form
here is the data in connectionstiring.xml
<ConnectionStrings>
<SqlConnectionString>Data Source=TEST-PC;Initial Catalog=DTR_Test;Integrated Security=False;User ID=sa;Password=@@@123</SqlConnectionString>
<DatabaseName>DB_Test</DatabaseName>
</ConnectionStrings>
private void btnFinish_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(cs))
{
if (goodCon == true)
{
string fname = Path.GetDirectoryName(Application.LocalUserAppDataPath) + "\\ConnectionStrings.xml";
XmlTextWriter writer = new XmlTextWriter(fname, null);
writer.Formatting = Formatting.Indented;
WriteConnectionStrings(writer, cs, osb);
writer.Close();
this.Close();
}
else
{
this.Close();
}
}
}
public void WriteConnectionStrings(XmlWriter writer, string sqlcon, string oledbcon)
{
writer.WriteStartElement("ConnectionStrings");
writer.WriteElementString("SqlConnectionString", sqlcon);
writer.WriteElementString("DatabaseName", dbname);
writer.WriteEndElement();
}