Click here to Skip to main content
15,880,392 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I am able to log into SSMS under Windows Authentication and SQL Server Authentication. But I am not seeing the Database anywhere in the SQL Server Management Studio. In Visual Studio, it goes to the localDb even though I have changed the connection string to have the db created in my SSMS.

Sometimes, I can see the name `BookServiceContext` under Data Connections in VS Server Explorer, but when I click on the connection I get this error message

> Cannot open database "BookServiceContext" requested by the login. The login failed.
Login failed for user 'MLS\AAnwar'.


What can I do so that it goes to the right connection in my SSMS?

What I have tried:

I have changed my connection string with my SSMS server, but the database still gets created in the localDb. I cannot seem to figure out why?

<!--<add name="BookServiceContext" connectionString="Data Source=(localdb)\MSSQLLocalDB; Initial Catalog=BookServiceContext-20170328200803; Integrated Security=True; MultipleActiveResultSets=True; AttachDbFilename=|DataDirectory|BookServiceContext-20170328200803.mdf"
      providerName="System.Data.SqlClient" />-->

    <add name="BookServiceContext" connectionString="Data Source=AA5570LT;Initial Catalog=BookServiceContext;Integrated Security=SSPI;" providerName="System.Data.SqlClient" />
Posted
Updated 29-Mar-17 4:21am
Comments
Dave Kreskowiak 28-Mar-17 23:43pm    
SSMS is not a database engine so you're not making any sense. The engines are LocalDB, SQLExpress and SQL Server Data Engine. SSMS is SQL Server Management Studio, not a database engine.

Your "Data Source" should be the DNS name or IP address of the SQL Server. So what is this "AA5570LT" you put in there?

I'm also going to question your use of Integrated Security but I'm ignoring it for now.
Member 13059365 29-Mar-17 6:45am    
AA5570LT is my SSMS Server name. I apologize if I am not using the correct terms, I am just trying to learn. I want the database to go under my SSMS Data connection in Visual Studio, instead of the LocalDB.

I have my connection string setup like that for all of my projects in VS.
CHill60 29-Mar-17 8:41am    
If you want to reply to a comment use the  Reply  button next to it so that the poster is notified of your response.
You need to change the connectionString to reflect the correct database. For example when you use SSMS from the desktop and attempt to Connect to Server in the pop-up dialog you will see "Server name" - that is what you put into "Data Source"
Member 13059365 29-Mar-17 9:10am    
Yes, that is it "AA5570LT". That's my server name.
CHill60 29-Mar-17 9:20am    
Then what makes you think you are connecting to LocalDb?

1 solution

After working my head off with this issue for the past 2 days, finally have it working. All I had to do was set the Project as a "StartUp Project" in Solution Explorer and it fixed the issue. The database was created in the right Server with all the data.
 
Share this answer
 
Comments
Dave Kreskowiak 29-Mar-17 12:50pm    
Setting the "Startup Project" has absolutely nothing at all do with databases. The just tells Visual Studio which project in your solution to start when you launch the app under the debugger.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900