This is a migrated thread and some comments may be shown as answers.

weird error - a connection string was referenced ... but could not be resolved...

6 Answers 246 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Sam Ur
Top achievements
Rank 2
Sam Ur asked on 14 Feb 2011, 11:05 PM
When i add my viewModel as a resource to a view (usercontrol) i get the following error - any advice on the matter would be awsome. (I'm in a learning process of MVVM and WPF using ORM so any help would be great). Thank you.

A connection string was referenced by name 'myConnection' but could not be resolved through the web.config or the executables app.config file.
   at Telerik.OpenAccess.RT.Adonet2Generic.Impl.DBDriver.connect(ConnectionString connectionString, IDictionary driverProps)
   at OpenAccessRuntime.Relational.sql.SqlDriver.InitializeFor(String url, Boolean noConnect, PropertySet props, Driver& driver, Connection& conn)
   at OpenAccessRuntime.Relational.RelationalStorageManagerFactory..ctor(StorageManagerFactoryBuilder b)
   at OpenAccessRuntime.storagemanager.StorageManagerFactoryBuilder.createSmfForURL()

6 Answers, 1 is accepted

Sort by
0
Sam Ur
Top achievements
Rank 2
answered on 15 Feb 2011, 11:25 AM
I guess i solved the issue.
0
Serge
Telerik team
answered on 17 Feb 2011, 03:54 PM
Hello Sam Ur,

 I am glad that you found the solution to your problem. The issue you experienced was most probably caused by the executing application not having the necessary connection string in its config file. 

Again I am glad you found the solution to your problem.

Greetings,
Serge
the Telerik team
0
Sam Ur
Top achievements
Rank 2
answered on 18 Feb 2011, 11:22 AM
Well actually it did have the necessary connection string and in runtime it works but in design time i get the mentioned error.

The problem occurs when i (I used car rental project for orm and wpf) call the following code in constructor...
...
public CarViewModel()
 {
            this.dataModel = new Models.CarModel();
            this.Brand = "WV";
            this.Cars = new ObservableCollection<Car>(dataModel.LoadCarsByMake(this.Brand));
}
...

But in runtime code get's executed as it should.
So basically if i try to fill observ. collection by calling a method that returns some data from model mentioned warning (error) occurs.

I solved this issue by using construtor as written in sample by Telerik :
public CarViewModel()
        {
            this.dataModel = new Models.CarModel();
            this.Cars = new ObservableCollection<Car>();
            this.Brand = "WV";
             
 
        }

And then used a trigger to listen to loaded event and fill my obsr. collection. That did the trick.
0
Serge
Telerik team
answered on 21 Feb 2011, 10:40 PM
Hello Sam Ur,

 Thank you for sharing your solution with us. This will most certainly help others if they stumble upon the same problem as you did. 

Please be sure to let us know if you face further trouble.

All the best,
Serge
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Mehdi
Top achievements
Rank 1
answered on 07 Jan 2013, 10:22 AM
this problem usually cause when two project have used in a solution. one for models and the other for your application.
solution:
the current connection string is in the library class(app.config).
you have to declare the connection string with the same name as library project connection Name in configuration file in your application .
thanks.
0
Mehdi
Top achievements
Rank 1
answered on 07 Jan 2013, 10:47 AM
this problem usually cause when two project have used in a solution. one for models and the other for your application.
solution:
the current connection string is in the library class(app.config).
you have to declare the connection string with the same name as library project connection Name in configuration file in your application .
thanks.
Tags
General Discussions
Asked by
Sam Ur
Top achievements
Rank 2
Answers by
Sam Ur
Top achievements
Rank 2
Serge
Telerik team
Mehdi
Top achievements
Rank 1
Share this question
or