PDA

View Full Version : DbProvider Configuration



freshj
03-02-2007, 02:57 PM
Sorry if I missed this in the documentation. How do I specify where the DatabaseConfigParser should pick up my DbProvider settings? Thanks in advance.:confused:


<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name='spring'>
<section name='parsers'
type='Spring.Context.Support.ConfigParsersSectionH andler, Spring.Core' />
</sectionGroup>
</configSections>

<spring>

<parsers>
<parser namespace='http://www.springframework.net/database'
type='Spring.Data.DatabaseConfigParser, Spring.Data'
schemaLocation='assembly://Spring.Data/Spring.Data/spring-database.xsd' />
</parsers>
</spring>
</configuration>

Mark Pollack
03-08-2007, 01:27 PM
Hi,

Take a look at Chapter 16 in the docs, it should help. The XML snip you listed is step 1 of the process, getting Spring.NET to recognize a custom schema for the database. The second step, is what you are looking for, specifying your provider settings. That is done with the following XML snip that is part of your Spring object definitions.



<objects xmlns='http://www.springframework.net'
xmlns:d="http://www.springframework.net/database">

<d:dbProvider id="DbProvider"
provider="System.Data.SqlClient"
connectionString="Data Source=(local);Database=Spring;User ID=springqa;Password=springqa;Trusted_Connection=F alse"/>

<object id="adoTemplate" type="Spring.Data.AdoTemplate, Spring.Data">
<property name="DbProvider" ref="DbProvider"/>
</object>

</objects>


You can take a look at the Data Access QuickStart and/or the Transactions QuickStart for a working example.

Cheers,
Mark