Results 1 to 5 of 5

Thread: [2005] Login failed to database error

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2006
    Posts
    375

    [2005] Login failed to database error

    Hey guys,

    My issue is as follows. I had my application working fine.
    My connection was the following
    "Provider=SQLNCLI;Server=W02\SQLEXPRESS;Database=db1;Trusted_Connection=yes"

    Then i dicided to add a datasource. After adding the datasource i think it created a user instance in the SQL Express database. And now im getting this error

    Code:
     Login failed for user 'a\me'.
    Cannot open database "db1" requested by the login. The login failed.
    Whenever i do the con.Open()

    How can i fix that?

    Now when i opend the SQL mgmt to see the database i can only see its name, but the tables are gone

    EDIT:
    I deleted the database from the SQL Express and deleted the dataset from VB.NEt and added the database again to the SQL Express. Now i can open the connections again in the VB.NET, but if i add the datasource again samething will happen. Im lost here
    Last edited by super_nOOb; Mar 8th, 2007 at 11:31 AM.

  2. #2
    Frenzied Member circuits2's Avatar
    Join Date
    Sep 2006
    Location
    Kansas City, MO
    Posts
    1,027

    Re: [2005] Login failed to database error

    If you use the wizard to add a datasource then it will add your datasource to the "Data Sources" window in VS. Select the database in the "Data Sources" window and then select "Do not copy to output folder" from the properties window. That should clear everything up.
    Show the love! Click (rate this post) under my name if I was helpful.

    My CodeBank Submissions: How to create a User Control | Move a form between Multiple Monitors (Screens) | Remove the MDI Client Border | Using Report Viewer with Visual Studio 2012 Express

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2006
    Posts
    375

    Re: [2005] Login failed to database error

    Actually i will tell you the whole story. I was using the wizard (add new data source - then select the path) and then when i was testing the connection i was getting an error msg
    Code:
      Generating user instances in SQL Server is disabled. Use sp_configure
     'user instances enabled' to generate user instances
    Then after that i had to reconfigure the SQL Express to user instances enabled with this command
    Code:
     SP_CONFIGURE ['user instances enabled'], 1
    GO
    RECONFIGURE
    GO
    And then i was able to add the database in the datasource.
    Then i binded my report to the datasource. And when i debugged the form (report) the report could not be generated.

    After that i tried to dubug my application and i was getting and error in the connection (which is using windows authentication). THe error message was saying that my user name (the name of the user in my machine) could not connect to the database

    So what i did was to uninstall the SQL server and install it back again, cuz i thought i had screwd it up. This took me nearly 3 hrs to get it all back on track.

    Then i did the whole thing again and got the same error and problem. So i found out that my user was creating an isntance inside od the dabase and "changing" the connection.
    So i deleted the database from the SQL server and added it again.
    Now im back where i was, i can debug my application correctly but whenever i add the datasource i get this problem

  4. #4
    Frenzied Member circuits2's Avatar
    Join Date
    Sep 2006
    Location
    Kansas City, MO
    Posts
    1,027

    Re: [2005] Login failed to database error

    Have you tried binding through code instead of at design time?
    Show the love! Click (rate this post) under my name if I was helpful.

    My CodeBank Submissions: How to create a User Control | Move a form between Multiple Monitors (Screens) | Remove the MDI Client Border | Using Report Viewer with Visual Studio 2012 Express

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2006
    Posts
    375

    Re: [2005] Login failed to database error

    I still didnt. Do you have any sample codes that i can try to use?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width