Good questions. In short I'm not too sure.
I created a DAAB configuration and saved it to the project. I then
added references to the EnterpriseLibrary to the project for Data,
Configuration and Common. I was attempting to follow the help files
that came with the Microsoft Patterns and Practices (June 2005)
install, but my interpretation of them lead me to my current position.
According to the properties pane in VS the EnterpriseLibrary(.Data)
version is v1.1.4322.
Any thoughts as to what additional information may be of use? I.e.
contents of dataconfiguration.config, code on the web page, etc?
<M>
Below is my dataConfiguration.config.
It'll get you started for google searching;
If you call the
DataFactory.CreateDatabase(); //no value passed in
you'll get the defaultInstance of "pubsInstance1". YOU CARE ABOUT THE
INSTANCE NAME, not the connection string name.
DataFactory.CreateDatabase("pubsInstance2") ; // youll get the the second
string, because you're explicitly telling it which one you want.
You also need to google
<databaseType name="Sql Server"
type="Microsoft.Practices.EnterpriseLibrary.Data.Sql.SqlDatabase,
Microsoft.EntLib.Data" />
(or at least the first half)
Because I think I shorted the filenames some.....aka ... my
"Microsoft.EntLib.Data" is too short from the default name. Find the
correct one thru google or sample code.
Basically, Microsoft.EntLib.Data is the dll name without the ".dll" with it.
Microsoft.EntLib.Data.dll is mine. The default is different.
..
Last tip.
If you're in webforms (which I assume you are because of this newsgroup),
then you put dataConfiguration.config in the root directory where web.config
is.
If you're in winforms, YOU NEED TO DO A POST BUILD EVENT, putting the
dataConfiguration.config file into the running folder /bin/ usually. (Just
mentioned for non web people)
Remember, the INSTANCE name is important. Not the connectionstring name,
not the connection string itself, just the instance name. (the
DataFactory.CreateDatabase method )
All of this should be in the quickstarts. But now you know what youre'
looking for.
start dataconfiguraiton.config file...
<?xml version="1.0" encoding="utf-8" ?>
<dataConfiguration>
<xmlSerializerSection
type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings,
Microsoft.EntLib.Data, Version=1.1.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="pubsInstance1"
xmlns="http://www.microsoft.com/practices/enterpriselibrary/08-31-2004/data">
<databaseTypes>
<databaseType name="Sql Server"
type="Microsoft.Practices.EnterpriseLibrary.Data.Sql.SqlDatabase,
Microsoft.EntLib.Data" />
<databaseType name="OleDB"
type="Microsoft.Practices.EnterpriseLibrary.Data.OleDbLib.OleDbDatabase,
Microsoft.EntLib.Data, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null" />
</databaseTypes>
<instances>
<instance name="pubsInstance1" type="Sql Server"
connectionString="pubsConnectionString1" />
<instance name="pubsInstance2" type="Sql Server"
connectionString="pubsConnectionString2" />
-->
</instances>
<connectionStrings>
<connectionString name="pubsConnectionString1">
<parameters>
<parameter name="database" value="pubs" isSensitive="false" />
<parameter name="Integrated Security" value="True" isSensitive="false"
/>
<!--
<parameter name="password" value="mypassword" isSensitive="true" />
<parameter name="user id" value="myusername" isSensitive="false" />
-->
<parameter name="server" value="SERVER1" isSensitive="false" />
</parameters>
</connectionString>
<connectionString name="pubsConnectionString2">
<parameters>
<parameter name="database" value="pubs" isSensitive="false" />
<parameter name="Integrated Security" value="True" isSensitive="false"
/>
<!--
<parameter name="password" value="mypassword" isSensitive="true" />
<parameter name="user id" value="myusername" isSensitive="false" />
-->
<parameter name="server" value="SERVER2" isSensitive="false" />
</parameters>
</connectionString>
</connectionStrings>
</enterpriseLibrary.databaseSettings>
</xmlSerializerSection>
</dataConfiguration>
end dataConfiguration.data file
start entries need to ADD to web.config
<configSections>
<section name="enterpriselibrary.configurationSettings"
type="System.Configuration.IgnoreSectionHandler, System, Version=1.0.5000.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</configSections>
<enterpriselibrary.configurationSettings
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
applicationName="Application"
xmlns="http://www.microsoft.com/practices/enterpriselibrary/08-31-2004/configuration">
<configurationSections>
<configurationSection name="dataConfiguration" encrypt="false">
<storageProvider xsi:type="XmlFileStorageProviderData" name="XML File
Storage Provider" path="dataConfiguration.config" />
<dataTransformer xsi:type="XmlSerializerTransformerData" name="Xml
Serializer Transformer">
<includeTypes />
</dataTransformer>
</configurationSection>
</configurationSections>
<includeTypes />
</enterpriselibrary.configurationSettings>