Solved

Read Connection string from xml file vb.net

Posted on 2014-11-13
4
431 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
  • 3
4 Comments
 
LVL 32

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 33

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 33

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 33

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now