[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 :eek: :confused: :cry:
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 :confused:
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.
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
Re: [2005] Login failed to database error
Have you tried binding through code instead of at design time?
Re: [2005] Login failed to database error
I still didnt. Do you have any sample codes that i can try to use?