Solved

Read Connection string from xml file vb.net

Posted on 2014-11-13
4
464 Views
Last Modified: 2014-11-18
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

0
Comment
Question by:Mike Eghtebas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 34

Assisted Solution

by:it_saige
it_saige earned 500 total points
ID: 40440155
Please provide the code used to build your xml reader object.

-saige-
0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 40440189
Hi Saige,

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

Mike
0
 
LVL 34

Accepted Solution

by:
Mike Eghtebas earned 0 total points
ID: 40440262
"Copy if newer" did the rick. It was on "Do not copy".

Thanks,

Mike
0
 
LVL 34

Author Closing Comment

by:Mike Eghtebas
ID: 40449349
When I checked "Copy to Output Directory" I notice it was on "Do not Copy".
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question