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

7 posts, 0 answers
  1. Sam Ur
    Sam Ur avatar
    35 posts
    Member since:
    Mar 2008

    Posted 14 Feb 2011 Link to this post

    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()
  2. Sam Ur
    Sam Ur avatar
    35 posts
    Member since:
    Mar 2008

    Posted 15 Feb 2011 Link to this post

    I guess i solved the issue.
  3. DevCraft banner
  4. Serge
    Admin
    Serge avatar
    375 posts

    Posted 17 Feb 2011 Link to this post

    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
  5. Sam Ur
    Sam Ur avatar
    35 posts
    Member since:
    Mar 2008

    Posted 18 Feb 2011 Link to this post

    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.
  6. Serge
    Admin
    Serge avatar
    375 posts

    Posted 21 Feb 2011 Link to this post

    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!
  7. Mehdi
    Mehdi avatar
    2 posts
    Member since:
    Jan 2013

    Posted 07 Jan 2013 Link to this post

    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.
  8. Mehdi
    Mehdi avatar
    2 posts
    Member since:
    Jan 2013

    Posted 07 Jan 2013 Link to this post

    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.
Back to Top
DevCraft banner