PDA

View Full Version : Strange problem


nickp
02-10-2006, 02:37 AM
I am working on a simple example, however I continue to get the following error upon execution:


PropertyAccessExceptionsException (1 errors); nested PropertyAccessExceptions are: \n[Spring.Objects.MethodInvocationException: Property 'ConnectionString' threw exception., Inner Exception: System.ArgumentException: Format of the initialization string does not conform to specification starting at index 0.\r\n at System.Data.Common.DbConnectionOptions.GetKeyValue Pair(String connectionString, Int32 currentPosition, StringBuilder buffer, Boolean useOdbcRules, String& keyname, String& keyvalue)\r\n at System.Data.Common.DbConnectionOptions.ParseIntern al(Hashtable parsetable, String connectionString, Boolean buildChain, Hashtable synonyms, Boolean firstKey)\r\n at System.Data.Common.DbConnectionOptions..ctor(Strin g connectionString, Hashtable synonyms, Boolean useOdbcRules)\r\n at System.Data.SqlClient.SqlConnectionString..ctor(St ring connectionString)\r\n at System.Data.SqlClient.SqlConnectionFactory.CreateC onnectionOptions(String connectionString, DbConnectionOptions previous)\r\n at System.Data.ProviderBase.DbConnectionFactory.GetCo nnectionPoolGroup(String connectionString, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions)\r\n at System.Data.SqlClient.SqlConnection.ConnectionStri ng_Set(String value)\r\n at System.Data.SqlClient.SqlConnection.set_Connection String(String value)

I get this error when I create an XmlObjectFactory and call GetObject("Database"). This is what my configuration file looks like, any suggestions?


<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net">
<object name="Database"
singleton="false"
type="SpringDemo.Database, SpringDemo">
<property name="Connection" ref="SqlConnectionObject" />
<property name="Command" ref ="SqlCommandObject" />
</object>
<object name="SqlConnectionObject"
singleton="false"
type="System.Data.SqlClient.SqlConnection, System.Data">
<property name="ConnectionString" value ="Testing" />
</object>
<object name="SqlCommandObject"
singleton="false"
type="System.Data.SqlClient.SqlCommand, System.Data">
</object>
</objects>

bchebrou
02-10-2006, 09:50 AM
Hello, I'm not sure but i think the problem is


value ="Testing"


Connection strings have a specified format, you can't set a simple string "Testing", try with a real connection string.

Ben

nickp
02-10-2006, 01:14 PM
I have actually tried a valid connection string, in fact in the demo I don't even attempt to actually connect yet. Passing an invalid connection string to the ConnectionString property of a SqlConnection should not cause the error I am seeing above.

Aleks Seovic
02-11-2006, 02:01 AM
Actually, according to your stacktrace it looks like it does. Try using valid SqlClient connection string and see what happens.

Regards,

Aleks