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 dataconfigurati on.config file and obtain the name
attribute nodes from all the connectionStrin g 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 dataconfigurati on.config file (relatively short).
<?xml version="1.0" encoding="utf-8"?>
<dataConfigurat ion>
<xmlSerializerS ection
type="Microsoft .Practices.Ente rpriseLibrary.D ata.Configurati on.DatabaseSett ings,
Microsoft.Pract ices.Enterprise Library.Data, Version=1.0.0.0 ,
Culture=neutral , PublicKeyToken= null">
<enterpriseLibr ary.databaseSet tings
xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
defaultInstance ="s09\Magic.pro d"
xmlns="http://www.microsoft.c om/practices/enterpriselibra ry/08-31-2004/data">
<databaseType s>
<databaseType name="Sql Server"
type="Microsoft .Practices.Ente rpriseLibrary.D ata.Sql.SqlData base,
Microsoft.Pract ices.Enterprise Library.Data, Version=1.0.0.0 ,
Culture=neutral , PublicKeyToken= null" />
</databaseTypes>
<instances>
<instance name="s11\eleve n.prod" type="Sql Server"
connectionStrin g="s11\eleven.p rod" />
<instance name="s09\Magic .prod" type="Sql Server"
connectionStrin g="s09\Magic.pr od" />
</instances>
<connectionStri ngs>
<connectionStri ng name="s11\eleve n.prod">
<parameters>
<parameter name="database" value="jt1" isSensitive="fa lse" />
<parameter name="Integrate d Security" value="True" isSensitive="fa lse" />
<parameter name="Max Pool Size" value="50" isSensitive="fa lse" />
<parameter name="Min Pool Size" value="0" isSensitive="fa lse" />
<parameter name="Connectio n Lifetime" value="30" isSensitive="fa lse" />
<parameter name="Pooling" value="True" isSensitive="fa lse" />
<parameter name="server" value="admsitsd bs11\eleven" isSensitive="fa lse" />
</parameters>
</connectionStrin g>
<connectionStri ng name="s09\Magic .prod">
<parameters>
<parameter name="Connectio n Lifetime" value="30" isSensitive="fa lse" />
<parameter name="database" value="s1" isSensitive="fa lse" />
<parameter name="Integrate d Security" value="True" isSensitive="fa lse" />
<parameter name="Max Pool Size" value="5" isSensitive="fa lse" />
<parameter name="Min Pool Size" value="0" isSensitive="fa lse" />
<parameter name="Pooling" value="True" isSensitive="fa lse" />
<parameter name="server" value="admsitsd bs09\magic" isSensitive="fa lse" />
</parameters>
</connectionStrin g>
</connectionStrin gs>
</enterpriseLibra ry.databaseSett ings>
</xmlSerializerSe ction>
</dataConfigurati on>
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.Sta rtupPath + "\" + "dataconfigurat ion.config"
ds = New DataSet
'ds.ReadXmlSche ma(filename)
ds.ReadXml(file name)
config = New XmlDataDocument (ds)
'config.Load(fi lename)
'nodePath =
"//dataConfigurati on/xmlSerializerSe ction/enterpriseLibra ry.databaseSett ings/connectionStrin gs"
'nodePath =
"/dataConfigurati on/xmlSerializerSe ction/enterpriseLibra ry.databaseSett ings/connectionStrin gs"
'nodePath =
"dataConfigurat ion/xmlSerializerSe ction/enterpriseLibra ry.databaseSett ings/connectionStrin gs"
'nodePath = "/dataConfigurati on/xmlSerializerSe ction/*/connectionStrin gs"
'nodePath = "/*/*/*/connectionStrin gs"
'nodePath =
"descendant::da taConfiguration/xmlSerializerSe ction/enterpriseLibra ry.databaseSett ings"
'nodePath =
"descendant::xm lSerializerSect ion/enterpriseLibra ry.databaseSett ings"
'nodePath = "//connectionStrin g"
nodePath = "/dataConfigurati on/xmlSerializerSe ction/*/connectionStrin gs"
nodeList = config.SelectNo des(nodePath)
'nodeList =
config.ChildNod es(0).ChildNode s(0).ChildNodes (0).SelectNodes ("//connectionStrin gs")
Catch ex As Exception
Throw ex
End Try
Any advice you can offer is appreciated! Thanks in advance!
JB 2 5088
This problem has been resolved. I received guidance in the
microsoft.publi c.dotnet.xml forum. Thanks
JB
"news.microsoft .com" <no************ ****@kc.rr.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.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 dataconfigurati on.config file and obtain the name attribute nodes from all the connectionStrin g 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 dataconfigurati on.config file (relatively short).
<?xml version="1.0" encoding="utf-8"?>
<dataConfigurat ion>
<xmlSerializerS ection type="Microsoft .Practices.Ente rpriseLibrary.D ata.Configurati on.DatabaseSett ings, Microsoft.Pract ices.Enterprise Library.Data, Version=1.0.0.0 , Culture=neutral , PublicKeyToken= null">
<enterpriseLibr ary.databaseSet tings xmlns:xsd="http ://www.w3.org/2001/XMLSchema" xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance" defaultInstance ="s09\Magic.pro d" xmlns="http://www.microsoft.c om/practices/enterpriselibra ry/08-31-2004/data">
<databaseType s>
<databaseType name="Sql Server" type="Microsoft .Practices.Ente rpriseLibrary.D ata.Sql.SqlData base, Microsoft.Pract ices.Enterprise Library.Data, Version=1.0.0.0 , Culture=neutral , PublicKeyToken= null" />
</databaseTypes>
<instances>
<instance name="s11\eleve n.prod" type="Sql Server" connectionStrin g="s11\eleven.p rod" />
<instance name="s09\Magic .prod" type="Sql Server" connectionStrin g="s09\Magic.pr od" />
</instances>
<connectionStri ngs>
<connectionStri ng name="s11\eleve n.prod">
<parameters>
<parameter name="database" value="jt1" isSensitive="fa lse" />
<parameter name="Integrate d Security" value="True" isSensitive="fa lse" />
<parameter name="Max Pool Size" value="50" isSensitive="fa lse" />
<parameter name="Min Pool Size" value="0" isSensitive="fa lse" />
<parameter name="Connectio n Lifetime" value="30" isSensitive="fa lse" />
<parameter name="Pooling" value="True" isSensitive="fa lse" />
<parameter name="server" value="admsitsd bs11\eleven" isSensitive="fa lse" />
</parameters>
</connectionStrin g>
<connectionStri ng name="s09\Magic .prod">
<parameters>
<parameter name="Connectio n Lifetime" value="30" isSensitive="fa lse" />
<parameter name="database" value="s1" isSensitive="fa lse" />
<parameter name="Integrate d Security" value="True" isSensitive="fa lse" />
<parameter name="Max Pool Size" value="5" isSensitive="fa lse" />
<parameter name="Min Pool Size" value="0" isSensitive="fa lse" />
<parameter name="Pooling" value="True" isSensitive="fa lse" />
<parameter name="server" value="admsitsd bs09\magic" isSensitive="fa lse" />
</parameters>
</connectionStrin g>
</connectionStrin gs>
</enterpriseLibra ry.databaseSett ings>
</xmlSerializerSe ction>
</dataConfigurati on>
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.Sta rtupPath + "\" + "dataconfigurat ion.config"
ds = New DataSet
'ds.ReadXmlSche ma(filename)
ds.ReadXml(file name)
config = New XmlDataDocument (ds)
'config.Load(fi lename) 'nodePath = "//dataConfigurati on/xmlSerializerSe ction/enterpriseLibra ry.databaseSett ings/connectionStrin gs"
'nodePath = "/dataConfigurati on/xmlSerializerSe ction/enterpriseLibra ry.databaseSett ings/connectionStrin gs"
'nodePath = "dataConfigurat ion/xmlSerializerSe ction/enterpriseLibra ry.databaseSett ings/connectionStrin gs"
'nodePath = "/dataConfigurati on/xmlSerializerSe ction/*/connectionStrin gs"
'nodePath = "/*/*/*/connectionStrin gs"
'nodePath = "descendant::da taConfiguration/xmlSerializerSe ction/enterpriseLibra ry.databaseSett ings"
'nodePath = "descendant::xm lSerializerSect ion/enterpriseLibra ry.databaseSett ings"
'nodePath = "//connectionStrin g"
nodePath = "/dataConfigurati on/xmlSerializerSe ction/*/connectionStrin gs"
nodeList = config.SelectNo des(nodePath)
'nodeList = config.ChildNod es(0).ChildNode s(0).ChildNodes (0).SelectNodes ("//connectionStrin gs") Catch ex As Exception
Throw ex
End Try Any advice you can offer is appreciated! Thanks in advance!
JB
This problem has been resolved. I received guidance in the
microsoft.publi c.dotnet.xml forum. Thanks
JB
"news.microsoft .com" <no************ ****@kc.rr.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.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 dataconfigurati on.config file and obtain the name attribute nodes from all the connectionStrin g 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 dataconfigurati on.config file (relatively short).
<?xml version="1.0" encoding="utf-8"?>
<dataConfigurat ion>
<xmlSerializerS ection type="Microsoft .Practices.Ente rpriseLibrary.D ata.Configurati on.DatabaseSett ings, Microsoft.Pract ices.Enterprise Library.Data, Version=1.0.0.0 , Culture=neutral , PublicKeyToken= null">
<enterpriseLibr ary.databaseSet tings xmlns:xsd="http ://www.w3.org/2001/XMLSchema" xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance" defaultInstance ="s09\Magic.pro d" xmlns="http://www.microsoft.c om/practices/enterpriselibra ry/08-31-2004/data">
<databaseType s>
<databaseType name="Sql Server" type="Microsoft .Practices.Ente rpriseLibrary.D ata.Sql.SqlData base, Microsoft.Pract ices.Enterprise Library.Data, Version=1.0.0.0 , Culture=neutral , PublicKeyToken= null" />
</databaseTypes>
<instances>
<instance name="s11\eleve n.prod" type="Sql Server" connectionStrin g="s11\eleven.p rod" />
<instance name="s09\Magic .prod" type="Sql Server" connectionStrin g="s09\Magic.pr od" />
</instances>
<connectionStri ngs>
<connectionStri ng name="s11\eleve n.prod">
<parameters>
<parameter name="database" value="jt1" isSensitive="fa lse" />
<parameter name="Integrate d Security" value="True" isSensitive="fa lse" />
<parameter name="Max Pool Size" value="50" isSensitive="fa lse" />
<parameter name="Min Pool Size" value="0" isSensitive="fa lse" />
<parameter name="Connectio n Lifetime" value="30" isSensitive="fa lse" />
<parameter name="Pooling" value="True" isSensitive="fa lse" />
<parameter name="server" value="admsitsd bs11\eleven" isSensitive="fa lse" />
</parameters>
</connectionStrin g>
<connectionStri ng name="s09\Magic .prod">
<parameters>
<parameter name="Connectio n Lifetime" value="30" isSensitive="fa lse" />
<parameter name="database" value="s1" isSensitive="fa lse" />
<parameter name="Integrate d Security" value="True" isSensitive="fa lse" />
<parameter name="Max Pool Size" value="5" isSensitive="fa lse" />
<parameter name="Min Pool Size" value="0" isSensitive="fa lse" />
<parameter name="Pooling" value="True" isSensitive="fa lse" />
<parameter name="server" value="admsitsd bs09\magic" isSensitive="fa lse" />
</parameters>
</connectionStrin g>
</connectionStrin gs>
</enterpriseLibra ry.databaseSett ings>
</xmlSerializerSe ction>
</dataConfigurati on>
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.Sta rtupPath + "\" + "dataconfigurat ion.config"
ds = New DataSet
'ds.ReadXmlSche ma(filename)
ds.ReadXml(file name)
config = New XmlDataDocument (ds)
'config.Load(fi lename) 'nodePath = "//dataConfigurati on/xmlSerializerSe ction/enterpriseLibra ry.databaseSett ings/connectionStrin gs"
'nodePath = "/dataConfigurati on/xmlSerializerSe ction/enterpriseLibra ry.databaseSett ings/connectionStrin gs"
'nodePath = "dataConfigurat ion/xmlSerializerSe ction/enterpriseLibra ry.databaseSett ings/connectionStrin gs"
'nodePath = "/dataConfigurati on/xmlSerializerSe ction/*/connectionStrin gs"
'nodePath = "/*/*/*/connectionStrin gs"
'nodePath = "descendant::da taConfiguration/xmlSerializerSe ction/enterpriseLibra ry.databaseSett ings"
'nodePath = "descendant::xm lSerializerSect ion/enterpriseLibra ry.databaseSett ings"
'nodePath = "//connectionStrin g"
nodePath = "/dataConfigurati on/xmlSerializerSe ction/*/connectionStrin gs"
nodeList = config.SelectNo des(nodePath)
'nodeList = config.ChildNod es(0).ChildNode s(0).ChildNodes (0).SelectNodes ("//connectionStrin gs") Catch ex As Exception
Throw ex
End Try Any advice you can offer is appreciated! Thanks in advance!
JB
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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
|
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, it does
not return the values from my web.config.
The web.config is located in the root of the web application. The
classic asp page that calls...
|
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 name="server" value="localhost"
isSensitive="false" />
<parameter name="database" value="MyDB"
isSensitive="false" />
<parameter name="Integrated Security"...
|
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
|
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 ConfigurationErrorException
whenever I do the following:
1. Modify and save the section in code using the...
| |
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 get the following error on the page:
Security Exception
Description: The application attempted to perform an operation not allowed
|
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):
System.Collections.Specialized.NameValueCollection SectionIndex =...
|
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 contains settings related
to business logic coded in that component. I can reference and load
the component but unable to read load the custom config...
|
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;
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |