473,387 Members | 1,502 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

reading dataconfiguration.config

Hi

After conducting a several searches, I wasn't sure where to post this
question. So my apologiesbefore hand for double posting this and possibly
posting to the wrong forum(s).

Okay, I have any application that uses the data access application building
block from Microsoft's Enterprise Library (patterns and practices site). I
want to allow the users to select the database connection. To do this, I
thought I could read the dataconfiguration.config file and obtain the name
attribute nodes from all the connectionString element nodes in the file.
Problem is, I can't get to them. This may be due to a lack of experience
and knowledge using XPath. I've tried a host of different XPath query
strings but I never get back more than one node and usually get zero nodes
when I should have two nodes.

Here is my dataconfiguration.config file (relatively short).

<?xml version="1.0" encoding="utf-8"?>

<dataConfiguration>

<xmlSerializerSection
type="Microsoft.Practices.EnterpriseLibrary.Data.C onfiguration.DatabaseSettings,
Microsoft.Practices.EnterpriseLibrary.Data, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null">

<enterpriseLibrary.databaseSettings
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
defaultInstance="s09\Magic.prod"
xmlns="http://www.microsoft.com/practices/enterpriselibrary/08-31-2004/data">

<databaseTypes>

<databaseType name="Sql Server"
type="Microsoft.Practices.EnterpriseLibrary.Data.S ql.SqlDatabase,
Microsoft.Practices.EnterpriseLibrary.Data, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null" />

</databaseTypes>

<instances>

<instance name="s11\eleven.prod" type="Sql Server"
connectionString="s11\eleven.prod" />

<instance name="s09\Magic.prod" type="Sql Server"
connectionString="s09\Magic.prod" />

</instances>

<connectionStrings>

<connectionString name="s11\eleven.prod">

<parameters>

<parameter name="database" value="jt1" isSensitive="false" />

<parameter name="Integrated Security" value="True" isSensitive="false" />

<parameter name="Max Pool Size" value="50" isSensitive="false" />

<parameter name="Min Pool Size" value="0" isSensitive="false" />

<parameter name="Connection Lifetime" value="30" isSensitive="false" />

<parameter name="Pooling" value="True" isSensitive="false" />

<parameter name="server" value="admsitsdbs11\eleven" isSensitive="false" />

</parameters>

</connectionString>

<connectionString name="s09\Magic.prod">

<parameters>

<parameter name="Connection Lifetime" value="30" isSensitive="false" />

<parameter name="database" value="s1" isSensitive="false" />

<parameter name="Integrated Security" value="True" isSensitive="false" />

<parameter name="Max Pool Size" value="5" isSensitive="false" />

<parameter name="Min Pool Size" value="0" isSensitive="false" />

<parameter name="Pooling" value="True" isSensitive="false" />

<parameter name="server" value="admsitsdbs09\magic" isSensitive="false" />

</parameters>

</connectionString>

</connectionStrings>

</enterpriseLibrary.databaseSettings>

</xmlSerializerSection>

</dataConfiguration>
Ok, and here is the code I'm trying to get to work. I've included commented
out XPath strings I've tried, which didn't work.

Dim filename As String

Dim ds As DataSet

Dim dt As DataTable

Dim row As DataRow

Dim config As XmlDataDocument

Dim node As XmlNode

Dim nodeList As XmlNodeList

Dim element As XmlElement

Dim nodePath As String

Try

filename = Application.StartupPath + "\" + "dataconfiguration.config"

ds = New DataSet

'ds.ReadXmlSchema(filename)

ds.ReadXml(filename)

config = New XmlDataDocument(ds)

'config.Load(filename)

'nodePath =
"//dataConfiguration/xmlSerializerSection/enterpriseLibrary.databaseSettings/connectionStrings"

'nodePath =
"/dataConfiguration/xmlSerializerSection/enterpriseLibrary.databaseSettings/connectionStrings"

'nodePath =
"dataConfiguration/xmlSerializerSection/enterpriseLibrary.databaseSettings/connectionStrings"

'nodePath = "/dataConfiguration/xmlSerializerSection/*/connectionStrings"

'nodePath = "/*/*/*/connectionStrings"

'nodePath =
"descendant::dataConfiguration/xmlSerializerSection/enterpriseLibrary.databaseSettings"

'nodePath =
"descendant::xmlSerializerSection/enterpriseLibrary.databaseSettings"

'nodePath = "//connectionString"

nodePath = "/dataConfiguration/xmlSerializerSection/*/connectionStrings"

nodeList = config.SelectNodes(nodePath)

'nodeList =
config.ChildNodes(0).ChildNodes(0).ChildNodes(0).S electNodes("//connectionStrings")

Catch ex As Exception

Throw ex

End Try

Any advice you can offer is appreciated! Thanks in advance!

JB
Nov 21 '05 #1
2 5072
This problem has been resolved. I received guidance in the
microsoft.public.dotnet.xml forum. Thanks

JB
"news.microsoft.com" <no****************@kc.rr.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi

After conducting a several searches, I wasn't sure where to post this
question. So my apologiesbefore hand for double posting this and possibly
posting to the wrong forum(s).

Okay, I have any application that uses the data access application
building block from Microsoft's Enterprise Library (patterns and practices
site). I want to allow the users to select the database connection. To
do this, I thought I could read the dataconfiguration.config file and
obtain the name attribute nodes from all the connectionString element
nodes in the file. Problem is, I can't get to them. This may be due to a
lack of experience and knowledge using XPath. I've tried a host of
different XPath query strings but I never get back more than one node and
usually get zero nodes when I should have two nodes.

Here is my dataconfiguration.config file (relatively short).

<?xml version="1.0" encoding="utf-8"?>

<dataConfiguration>

<xmlSerializerSection
type="Microsoft.Practices.EnterpriseLibrary.Data.C onfiguration.DatabaseSettings,
Microsoft.Practices.EnterpriseLibrary.Data, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null">

<enterpriseLibrary.databaseSettings
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
defaultInstance="s09\Magic.prod"
xmlns="http://www.microsoft.com/practices/enterpriselibrary/08-31-2004/data">

<databaseTypes>

<databaseType name="Sql Server"
type="Microsoft.Practices.EnterpriseLibrary.Data.S ql.SqlDatabase,
Microsoft.Practices.EnterpriseLibrary.Data, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null" />

</databaseTypes>

<instances>

<instance name="s11\eleven.prod" type="Sql Server"
connectionString="s11\eleven.prod" />

<instance name="s09\Magic.prod" type="Sql Server"
connectionString="s09\Magic.prod" />

</instances>

<connectionStrings>

<connectionString name="s11\eleven.prod">

<parameters>

<parameter name="database" value="jt1" isSensitive="false" />

<parameter name="Integrated Security" value="True" isSensitive="false" />

<parameter name="Max Pool Size" value="50" isSensitive="false" />

<parameter name="Min Pool Size" value="0" isSensitive="false" />

<parameter name="Connection Lifetime" value="30" isSensitive="false" />

<parameter name="Pooling" value="True" isSensitive="false" />

<parameter name="server" value="admsitsdbs11\eleven" isSensitive="false"
/>

</parameters>

</connectionString>

<connectionString name="s09\Magic.prod">

<parameters>

<parameter name="Connection Lifetime" value="30" isSensitive="false" />

<parameter name="database" value="s1" isSensitive="false" />

<parameter name="Integrated Security" value="True" isSensitive="false" />

<parameter name="Max Pool Size" value="5" isSensitive="false" />

<parameter name="Min Pool Size" value="0" isSensitive="false" />

<parameter name="Pooling" value="True" isSensitive="false" />

<parameter name="server" value="admsitsdbs09\magic" isSensitive="false" />

</parameters>

</connectionString>

</connectionStrings>

</enterpriseLibrary.databaseSettings>

</xmlSerializerSection>

</dataConfiguration>
Ok, and here is the code I'm trying to get to work. I've included
commented out XPath strings I've tried, which didn't work.

Dim filename As String

Dim ds As DataSet

Dim dt As DataTable

Dim row As DataRow

Dim config As XmlDataDocument

Dim node As XmlNode

Dim nodeList As XmlNodeList

Dim element As XmlElement

Dim nodePath As String

Try

filename = Application.StartupPath + "\" + "dataconfiguration.config"

ds = New DataSet

'ds.ReadXmlSchema(filename)

ds.ReadXml(filename)

config = New XmlDataDocument(ds)

'config.Load(filename)

'nodePath =
"//dataConfiguration/xmlSerializerSection/enterpriseLibrary.databaseSettings/connectionStrings"

'nodePath =
"/dataConfiguration/xmlSerializerSection/enterpriseLibrary.databaseSettings/connectionStrings"

'nodePath =
"dataConfiguration/xmlSerializerSection/enterpriseLibrary.databaseSettings/connectionStrings"

'nodePath = "/dataConfiguration/xmlSerializerSection/*/connectionStrings"

'nodePath = "/*/*/*/connectionStrings"

'nodePath =
"descendant::dataConfiguration/xmlSerializerSection/enterpriseLibrary.databaseSettings"

'nodePath =
"descendant::xmlSerializerSection/enterpriseLibrary.databaseSettings"

'nodePath = "//connectionString"

nodePath = "/dataConfiguration/xmlSerializerSection/*/connectionStrings"

nodeList = config.SelectNodes(nodePath)

'nodeList =
config.ChildNodes(0).ChildNodes(0).ChildNodes(0).S electNodes("//connectionStrings")

Catch ex As Exception

Throw ex

End Try

Any advice you can offer is appreciated! Thanks in advance!

JB

Nov 21 '05 #2
This problem has been resolved. I received guidance in the
microsoft.public.dotnet.xml forum. Thanks

JB

"news.microsoft.com" <no****************@kc.rr.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi

After conducting a several searches, I wasn't sure where to post this
question. So my apologiesbefore hand for double posting this and possibly
posting to the wrong forum(s).

Okay, I have any application that uses the data access application
building block from Microsoft's Enterprise Library (patterns and practices
site). I want to allow the users to select the database connection. To
do this, I thought I could read the dataconfiguration.config file and
obtain the name attribute nodes from all the connectionString element
nodes in the file. Problem is, I can't get to them. This may be due to a
lack of experience and knowledge using XPath. I've tried a host of
different XPath query strings but I never get back more than one node and
usually get zero nodes when I should have two nodes.

Here is my dataconfiguration.config file (relatively short).

<?xml version="1.0" encoding="utf-8"?>

<dataConfiguration>

<xmlSerializerSection
type="Microsoft.Practices.EnterpriseLibrary.Data.C onfiguration.DatabaseSettings,
Microsoft.Practices.EnterpriseLibrary.Data, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null">

<enterpriseLibrary.databaseSettings
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
defaultInstance="s09\Magic.prod"
xmlns="http://www.microsoft.com/practices/enterpriselibrary/08-31-2004/data">

<databaseTypes>

<databaseType name="Sql Server"
type="Microsoft.Practices.EnterpriseLibrary.Data.S ql.SqlDatabase,
Microsoft.Practices.EnterpriseLibrary.Data, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null" />

</databaseTypes>

<instances>

<instance name="s11\eleven.prod" type="Sql Server"
connectionString="s11\eleven.prod" />

<instance name="s09\Magic.prod" type="Sql Server"
connectionString="s09\Magic.prod" />

</instances>

<connectionStrings>

<connectionString name="s11\eleven.prod">

<parameters>

<parameter name="database" value="jt1" isSensitive="false" />

<parameter name="Integrated Security" value="True" isSensitive="false" />

<parameter name="Max Pool Size" value="50" isSensitive="false" />

<parameter name="Min Pool Size" value="0" isSensitive="false" />

<parameter name="Connection Lifetime" value="30" isSensitive="false" />

<parameter name="Pooling" value="True" isSensitive="false" />

<parameter name="server" value="admsitsdbs11\eleven" isSensitive="false"
/>

</parameters>

</connectionString>

<connectionString name="s09\Magic.prod">

<parameters>

<parameter name="Connection Lifetime" value="30" isSensitive="false" />

<parameter name="database" value="s1" isSensitive="false" />

<parameter name="Integrated Security" value="True" isSensitive="false" />

<parameter name="Max Pool Size" value="5" isSensitive="false" />

<parameter name="Min Pool Size" value="0" isSensitive="false" />

<parameter name="Pooling" value="True" isSensitive="false" />

<parameter name="server" value="admsitsdbs09\magic" isSensitive="false" />

</parameters>

</connectionString>

</connectionStrings>

</enterpriseLibrary.databaseSettings>

</xmlSerializerSection>

</dataConfiguration>
Ok, and here is the code I'm trying to get to work. I've included
commented out XPath strings I've tried, which didn't work.

Dim filename As String

Dim ds As DataSet

Dim dt As DataTable

Dim row As DataRow

Dim config As XmlDataDocument

Dim node As XmlNode

Dim nodeList As XmlNodeList

Dim element As XmlElement

Dim nodePath As String

Try

filename = Application.StartupPath + "\" + "dataconfiguration.config"

ds = New DataSet

'ds.ReadXmlSchema(filename)

ds.ReadXml(filename)

config = New XmlDataDocument(ds)

'config.Load(filename)

'nodePath =
"//dataConfiguration/xmlSerializerSection/enterpriseLibrary.databaseSettings/connectionStrings"

'nodePath =
"/dataConfiguration/xmlSerializerSection/enterpriseLibrary.databaseSettings/connectionStrings"

'nodePath =
"dataConfiguration/xmlSerializerSection/enterpriseLibrary.databaseSettings/connectionStrings"

'nodePath = "/dataConfiguration/xmlSerializerSection/*/connectionStrings"

'nodePath = "/*/*/*/connectionStrings"

'nodePath =
"descendant::dataConfiguration/xmlSerializerSection/enterpriseLibrary.databaseSettings"

'nodePath =
"descendant::xmlSerializerSection/enterpriseLibrary.databaseSettings"

'nodePath = "//connectionString"

nodePath = "/dataConfiguration/xmlSerializerSection/*/connectionStrings"

nodeList = config.SelectNodes(nodePath)

'nodeList =
config.ChildNodes(0).ChildNodes(0).ChildNodes(0).S electNodes("//connectionStrings")

Catch ex As Exception

Throw ex

End Try

Any advice you can offer is appreciated! Thanks in advance!

JB

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Sami | last post by:
Hello, I have this problem that I need your help with : I am reading a config file that contain the following : 2004 update
3
by: spacekid | last post by:
Hi there I am exposing a c# assembly as a COM component (regasm /codebase) and calling it from classic asp. When I try to call the ConfigurationSettings.AppSettings function in the c# assembly,...
0
by: ABC | last post by:
How to set dataConfiguration section on DAAB if I set Integrated Security = false? What is the parameter name of user id? <connectionString name="MyDatabase"> <parameters> <parameter...
1
by: comic_rage | last post by:
Hi, I am trying to read from my application config file and keep getting null. Here is my config file My application is called SampleApp.exe
10
by: Ryan | last post by:
I've created a custom configuration section that inherits (naturally) from System.Configuration.ConfigurationSection. The configuration section is working 99% fine, however I keep coming across a...
5
by: alf | last post by:
Hi folks, I'm trying to read a web.config section using RoleManagerSection settings = (RoleManagerSection)System.Configuration.ConfigurationManager.GetSection("system.web/roleManager"); and I...
9
by: Milsnips | last post by:
Hi all. i'm tryng to implement the Rewrite.NET url rewritining functionality into a test project i've created, however i am hitting a problem at this line (direct from the web example): ...
1
by: M Irfan | last post by:
Hello all, Recently I have started working in .NET 2.0. I am developing a web service application that references a DLL component written in C# 2.0. The component has its own config file which...
1
by: vijayarl | last post by:
Hi Everyone, i have the written this logic : basically a file operation open (CONFIGFILE, "$config_file") or die; while (<CONFIGFILE>) { chomp;
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.