In a VB.NET windows application, I am trying to read the entire "value=" from the following line in a web.config:
<add key="ConnectionString" value="provider=SQLOLEDB;Data Source=servername;Database=databasename;UID=username;Password=password" />
Here's the code (this code successfully reads through the web.config file, but never returns the value for "value"
:
' open the document:
' "filename" is a string which
' is the location of the web.config
Dim reader as New XmlTextReader(filename)
' move to the start of the document
reader.MoveToContent()
' go through the document
Dim test As String
Do While reader.Read
' kind of node
Select Case reader.NodeType
' check for start of element
Case XmlNodeType.Element
' if it is an element start, is it "value"
if reader.Name = "Value" Then
test = reader.Value
MessageBox.Show (test)
Any Ideas why this doesn't work?
<add key="ConnectionString" value="provider=SQLOLEDB;Data Source=servername;Database=databasename;UID=username;Password=password" />
Here's the code (this code successfully reads through the web.config file, but never returns the value for "value"
' open the document:
' "filename" is a string which
' is the location of the web.config
Dim reader as New XmlTextReader(filename)
' move to the start of the document
reader.MoveToContent()
' go through the document
Dim test As String
Do While reader.Read
' kind of node
Select Case reader.NodeType
' check for start of element
Case XmlNodeType.Element
' if it is an element start, is it "value"
if reader.Name = "Value" Then
test = reader.Value
MessageBox.Show (test)
Any Ideas why this doesn't work?