title: Read/write Database Connection string in xml file using c# Windows Form
body: <p>I am developing an c# application in which I need to fetch data from oracle database server.
  In my application I do not want to make a <strong>hard coded connection string</strong> because sometimes we have to connect it with different DB (for testing purpose it has same schema). </p>
  
  <p>For this I have a plan that I create an <strong>xml</strong> file and a new form(with admin rights) using this form I update/insert database credentials in xml file or use <strong>app.config</strong>, but the problem is i don't have any idea how to read and write xml file in predefined manner (in same manner as a connection string should be).</p>
  
  <p>Can you please help me out for creating new xml file or have any batter idea?</p>
  
  <p>how about this code?</p>
  
  <pre><code>public static string ClientName, DbType, ConnectionString;
          static DB()
          {
              try
              {
                  DataTable Dt = new DataTable("Settings");
                  DataColumn Client = new DataColumn("Client", typeof(string));
                  DataColumn DataBaseType = new DataColumn("DataBaseType", typeof(string));
  
                  DataColumn ConString = new DataColumn("ConnectionString", typeof(string));
                  Dt.Columns.Add(Client);
                  Dt.Columns.Add(DataBaseType);
                  Dt.Columns.Add(ConString);
                  Dt.ReadXml(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\Settings.xml");
                  DB.ClientName = Dt.Rows[0]["Client"].ToString();
                  DB.DbType = Dt.Rows[0]["DataBaseType"].ToString();
                  DB.Port = Dt.Rows[0]["Port"].ToString();
                  DB.ConnectionString = Dt.Rows[0]["ConnectionString"].ToString();
              }
              catch(Exception ex)
               {
              // Exception message
               }
  </code></pre>
  
  <p>and xml file code is </p>
  
  <pre><code>&lt;?xml version="1.0" standalone="yes"?&gt;
  &lt;DocumentElement&gt;
      &lt;Settings&gt;
          &lt;Client&gt;DSCL&lt;/Client&gt;
          &lt;DataBaseType&gt;ORACLE&lt;/DataBaseType&gt;
  
              &lt;ConnectionString&gt;providerName=system.data.oracleclient;User ID=****;password=****;Data Source=*****;Persist Security Info=True;Provider=OraOLEDB.Oracle;&lt;/ConnectionString&gt;
  
    &lt;/Settings&gt;
  &lt;/DocumentElement&gt;
  </code></pre>