So, I have a simple code to get the value of connection string from XML.
connectionString = root.<TestDB>.Value.ToString
As you can see, "TestDB" is the element name that gives me connection name. I want to replace this "TestDB" with a variable. Sadly, I am unable to figure out how to do that.
Below is the XML I am using.
<connections> <TestDB>Data Source=GAMING;Initial Catalog=BasicDB;User ID=sa;[email protected]</TestDB> <TestDBConnectionType>SQL</TestDBConnectionType> <NewDB>ConnectionType=SQL;Data Source=GAMING;Initial Catalog=BasicDB;User ID=sa;[email protected]</NewDB> <NewDBConnectionType>SQL</NewDBConnectionType> </connections>
I want to get the connection string based on which connection name programmer uses.