Connection Problems

Topics: Data Access Application Block
Jun 4, 2010 at 6:03 PM
I don't know if the Data Application Block Quick Start sample doesn't work or something is wrong in the app.config file or my Sql Server 2008 Express instance needs reconfiguring. Nevertheless, when I run the sample I immediately get the exception "Login failed for user Laptop1\Owner". When I go to Sql Server Management Studio, under the SQLExpress instance, the Security tab shows the user Laptop1\Owner. So it looks okay to me. Thank you for your time,
Jun 7, 2010 at 12:51 AM

Did you check if that user is mapped to the database you're trying to access?  Right click on the user, click Properties and navigate to User Mapping, check if the database you're trying to connect to is checked and the appropriate Database Role Membership is checked.


Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.

Jun 7, 2010 at 3:07 PM

Thank you for responding. 

I managed to get the DataAccessQuickStart sample application working.  All it apparently needed was to rerun the SetupQuickStartDB.bat file.  However, when I create my own application that uses DAAB I get the same error that I was getting on the DataAccessQuickStart sample prior to running the SetupQuickStartDB.bat file: 'Login failed for user Laptop1\Owner'.  I don't see any option setting within this SetupQuickStartDB.bat file that configures permissions for users.  So I attached my database to the SQLExpress instance using SSMS 2008.  Then followed your advice then detached my database and reran my application.  And I still received this login error.  My understanding of the DAAB is that every time a data request is required, that is select, inserts, updates or deletes, the DAAB automatically re-attaches to the database, fulfills the request and then detaches.  Is that correct? Within my application do I need to write code that attaches the database to the server?  As an additional side question, is the DAAB library appropriate for a windows application that talks to a local database?  The more important question at this moment is, what do I need to do to allow my Laptop1\Owner to connect to the database?  Again thank you for your time.

Jun 7, 2010 at 6:36 PM

As a test I decided to manually attach my database then run my application.  Amazingly enough it ran just fine, it was able to do selects and updates and everything else.  Now I am thinking that the error message is misleading.  The problem is not that Laptop1\Owner can't connect, but rather the DAAB can't programmatically attach my database!?  Does that make any sense at all?  More importantly, what do I do about it?  Again, if I don't first manually attach my database, then I get the login error.   The DataAccessQuickStart sample application doesn't require a manual attach but my application does for some reason.  I need help.  Thank you again.


Jun 8, 2010 at 10:42 AM


The DAAB doesn't have a way of programmatically attaching or setting up a database. DAAB was not built to do that functionality. DAAB is a wrapper for ADO.NET and was built on top of it to simplify the most common techniques for accessing a database from your application. For more details you can check the documentation

As for the log in error encountered while the database is not attached, it is by design in SQL Server to throw this error given that the database that are being accessed is not available. The DataAccessQuickStart sample doesn't require you to manually attach its database because it is actually been attached when you have run the SetUpQuickStartsDB.bat script. HTH. 

Gino Terrado
Global Technology and Solutions
Avanade, Inc.