Link to home
Start Free TrialLog in
Avatar of Mike Eghtebas
Mike EghtebasFlag for United States of America

asked on

Read Connection string from xml file vb.net

The project runs fine with Line 12 below. But, with lines 9 and 11 it fails.

Question: Why line 9 is not reading the connection string? Is shows "nothing" via intelesens.

<?xml version="1.0" encoding="utf-8" ?>
<connection>
Data Source=.\SQLEXPRESS12;AttachDbFilename=|DataDirectory|\NORTHWND.MDF;Integrated Security=True;User Instance=True
</connection>


Protected Shared Function GetNWConString() As String

Dim xmlReader As New XmlTextReader("csNorthwind.xml")

Return xmlReader.ReadElementString("connection")
'Return "Data Source=.\SQLEXPRESS12;AttachDbFilename=|DataDirectory|\NORTHWND.MDF;Integrated Security=True;User Instance=True"
End Function

Open in new window

SOLUTION
Avatar of it_saige
it_saige
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mike Eghtebas

ASKER

Hi Saige,

I have typed it manually. I am not aware of utility that builds xml file like this.

Mike
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
When I checked "Copy to Output Directory" I notice it was on "Do not Copy".