Thursday, March 22, 2012

Cannot open user default database. Login failed.

Hi,

I got this application system having SQLExpress as database (ABCSystem.mdf). I'm connecting to the database thru connection string specifying database path in App.config.

At the same time, I got two paths for the mdf files. The first one is the path for my database project while the second one is the path to conduct testing. (This means that I got identical ABCSystem.mdf in two paths)

1) C:\Program Files\Company ABC\ABCDatabaseProject\

2) C:\Program Files\Company ABC Limited\ABCSystem\Database\

In my development machine, I can run my application where database path is testing path (number 2).

When I tried to copy the ABCSystem.mdf and ABCSystem_log.LDF and my application program files to another PC to test, I got the subject error message. (note that I copy program files under directory "C:\Program Files\Company ABC Limited\ABCSystem\" and mdf files under "C:\Program Files\Company ABC Limited\ABCSystem\Database\")

I try to edit path from database testing path to database project path in app.config, run the application, and notice that it is running OK.

What seems to cause the problem? Coz I need the database in the testing path which is "C:\Program Files\Company ABC Limited\ABCSystem\Database\" AND NOT "C:\Program Files\Company ABC\ABCDatabaseProject\".

Thanks alot for your kind attention.

Try this first, and then check your string accordingly:

http://msdn2.microsoft.com/en-us/library/ms345332.aspx

Buck Woody

|||I'm having this identical issue with an ODBC connection.
After wasting hours, I realized I only get the error when I try to change database name. (e.g. from a development to a production server). Based upon everything I've tried, I determined you CANNOT change server name in a Crystal report programmatically as in the Crystal sample code. It may be a possible to change servers if using a command based report (explicit SQL query), but our reports all use tables so a trial would be irrelevant.

No comments:

Post a Comment