PDA

View Full Version : Help Connecting to SQL Server Express 2005


reza_rahman
06-08-2007, 03:51 AM
I'm using the following DB Provider to try to connect to SQL Server Express 2005 using Windows authentication:

<db:dbProvider id="dbProvider"
provider="System.Data.SqlClient"
connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=HelloSpring;Integrated Security=True"/>

Is this correct? I'm having a problem instantiating the bean...Maybe the db namespace is not resolving?

Here is the stack trace:

System.Configuration.ConfigurationErrorsException was unhandled
Message="Error instantiating context 'spring.root'."
Source="System.Configuration"
BareMessage="Error instantiating context 'spring.root'."
Line=0
StackTrace:
at System.Configuration.BaseConfigurationRecord.Evalu ateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult)
at System.Configuration.BaseConfigurationRecord.Evalu ate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSe ctionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSe ctionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSe ctionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSe ction(String configKey, Boolean getLkg, Boolean checkPermission)
at System.Configuration.BaseConfigurationRecord.GetSe ction(String configKey)
at System.Configuration.ClientConfigurationSystem.Sys tem.Configuration.Internal.IInternalConfigSystem.G etSection(String sectionName)
at System.Configuration.ConfigurationManager.GetSecti on(String sectionName)
at Spring.Util.ConfigurationUtils.GetSection(String sectionName)
at Spring.Context.Support.ContextRegistry.InitializeC ontextIfNeeded()
at Spring.Context.Support.ContextRegistry.GetContext( )
at HelloSpring.Hello.Main(String[] args) in C:\Documents and Settings\Reza Rahman\My Documents\Visual Studio 2005\Projects\HelloSpring\HelloSpring\Program.cs:l ine 23
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
at System.Runtime.Hosting.ManifestRunner.ExecuteAsAss embly()
at System.Runtime.Hosting.ApplicationActivator.Create Instance(ActivationContext activationContext, String[] activationCustomData)
at System.Runtime.Hosting.ApplicationActivator.Create Instance(ActivationContext activationContext)
at Microsoft.VisualStudio.HostingProcess.HostProc.Run UsersAssemblyDebugInZone()
at System.Threading.ThreadHelper.ThreadStart_Context( Object state)
at System.Threading.ExecutionContext.Run(ExecutionCon text executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

Nop
06-08-2007, 06:31 AM
Hi.

You have to add the following code to resolve the db namespace:

<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>


Best regards.
Nop.

reza_rahman
06-08-2007, 02:56 PM
Thanks a lot. that worked...

Bruno Baia
06-08-2007, 03:13 PM
Hi,

<db:dbProvider id="dbProvider"
provider="System.Data.SqlClient"
connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=HelloSpring;Integrated Security=True"/>

The provider "System.Data.SqlClient" is not valid.
Here are providers availlaible with 1.1 M1 :

SqlServer-1.1
SqlServer-2.0
SqlServerCe-3.1
OleDb-1.1
OleDb-2.0
OracleClient-2.0
OracleODP-2.0
MySql
Npgsql-1.0

You should install XSD schema within VS2005 to get intellisense :
Schemas are located in the directory <distribution>/doc/schema/, copy *.xsd files to the VS2005 schema directory :
<Microsoft Visual Studio 8 INSTALL DIR>\Xml\Schemas\





<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>


FYI, this is enough now :

<parsers>
<parser type="Spring.Data.DatabaseConfigParser, Spring.Data" />
</parsers>



HTH,
Bruno

Bruno Baia
06-08-2007, 03:17 PM
The provider "System.Data.SqlClient" is not valid.
I was wrong, "System.Data.SqlClient" is an alias name for "SqlServer-2.0".
In Spring.Data/Data/Common/dbproviders.xml :

<alias name="SqlServer-2.0" alias="System.Data.SqlClient"/>

So this is OK :)

Bruno