db Access problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • justSteve
    New Member
    • Feb 2008
    • 1

    db Access problem

    I'm working with a .sln that has 2 projects...one has db connectivity, the other is intended to call methods of the db-connected project. This isn't a formal 'DAL' situation but it's along those lines - 2 projects; one for data access, one for displaying data.

    The class in the UI project instantiates an object in the Data project:
    private MyData.MyDataPr ovider emsData = new MyData.MyDataPr ovider();

    and then calls methods via:
    string customerList = emsData.GetCust omerList();

    The process works as long as I define a connection string in the UI App.config file...but I think I shouldn't have to carry that information in the UI project. From my perspective...a ll i'm doing is calling a method in a referenced project and db connectivity is up to _that project...not the UI project.

    As soon as I remove reference from UI I get a 'Object Reference not set to an instance of an object.'

    I'm using the Enterprise Library Data Block...the error is occurring in:
    Database db = DatabaseFactory .CreateDatabase ();

    The question is why that method wants to refer back to the calling method for the database connection string. If I call from within the data project stuff works. I thought separating responsibility as 'a good thing'.

    many thankx for any thoughts.
Working...