SQL Server cannot connect to Visual Studio using Server Explorer - c#

I'm a beginner developer, when I tried to connect database to Visual Studio by means of the Server Explorer, this error message pops up.
Does anyone know how to fix this?

Related

How do I automatically connect a database to an SQL Server through Visual Studio 2022?

I just installed SQL Server Express 2017 on my Windows 11 laptop. I'm now trying to write a project in C# using VS 2022 and every time I try to create a new database by selecting Add -> New Item, then selecting Service-based Database and clicking the Add button, I keep getting this message:
This is the error message I get
I'm figuring I have to some how change the server name, remove any password to it if there is one on the SQL Server side and probably set an option in Visual Studio.
I tried going into SQL Server 2017 and change the server name, remove the password, and set it so it automatically starts.
I also went into Visual Studio 2022 and looked for options that could be changed to link up to that serve. I didn't find any.

How to Connect the database from Testing(QA) server into SSMS(SQL Server 2017)?

We have a previously created a project in Coldfusion -- it is slow in bringing the data back from the server, so the team has decided to convert from Coldfusion API's to Entity Framework.Net Core API's.
Visual studio is failing to connect to QA(Testing)Server, so my API's do not work.
Now, I am trying to connect the database from QA Server -- database gets open only in visual studio 2017, and I am unable to open in SQL Server(SSMS) due to permission issue.
In order to open the same database of QA Server into SSMS(SQL Server 2017), what should I do?
I want my API's to connect with the server and bring the data back.
Does anyone go through such an issue before? Any Help will be appreciated.
Thanks in advance.

Login failed for user domain\user in vs17

I have tried to open a mdf-file getting the Loging failed for user domain\user. ConnectionString to the existing mdf-file
<add name="NWindConnectionString" connectionString="data source=(localdb)\mssqllocaldb;attachdbfilename=|DataDirectory|\NWind.mdf;integrated security=True;connect timeout=120" providerName="System.Data.SqlClient" />
I tried to create a mdf-file with visual studio 2017 in a .NET MVC5 project getting the Loging failed for user domain\user.
I have installed SQL Server 2014.
I can connect perfectly to the SQL Server Management Studio with my windows credentials.
SQL Server is configured to use Windows credentials.
I opened the mdf-file of the project (is a GitHub project) correctly with SQL Server Managment Studio attaching the file.
Steps to add new MDF-File to the project:
Add New Item into App_Data folder
Service-based Database -> Button Add
Then error promps
To get an idea which process I am following https://www.linkedin.com/pulse/service-based-database-file-visual-studio-bharath-gunupati
Attempt to open an existing mdf-file(NWind.mdf) in my project
Any clue what can be wrong with Visual Studio 17?
Could Be a misconfiguration of the Visual Studio?
For now I uninstalling SQL Server 2014 and installing SQL Server 2017, hope that this fix some misconfiguration of Visual Studio.
After install and unistall still not working
I found the solution.
Apparently the sql server localdb installed with visualstudio was damage or something. So I run this on command line window.
sqllocaldb stop mssqllocaldb
sqllocaldb delete mssqllocaldb
sqllocaldb start "MSSQLLocalDB"
Although, my Visual Studio needed a complement to connect properly with SQL Server.
This is what actually fixed my login for user error.
In case you guys require this Complement for Visual Studio 2017 complement, but not sure if that was part of the solution.

LightSwitch build fails using SQL Server 2014 LocalDB and Visual Studio 2013

I have SQL Server 2014 installed and want to use localdb\v12.0 in Visual Studio. I found this post and understand how to connect to localdb using SQL Server Object Explorer successfully. Now I have created a LightSwitch project in Visual Studio 2013 and when building it throws exception:
An error occured while establishing a connection to SQL Server
instance '(LocalDB)\v11.0'.
Seems it is looking for SQL Server 2012 to create the development database in Bin\Data and I don't have SQL Server 2012 so there is no localdb\v11.0 on the system. So
Why does VS 2013 try to use localdb\v11.0?
How can I force Visual Studio to use localdb\v12.0 when building the project?
I tried changing the _IntrinsicData connection string in web.config but when building again it throws the same exception trying to use localdb\v11.0 which belongs to SQL Server 2012!
Ok after spending lots of time I found what was the problem! Here is the cause and solution:
LightSwitch uses SQL Express LocalDB to store information such as User and Roles when building the project (this is called development database). There is no problem with SQL Server 2012 but if SQL Server 2014 is installed something force the LightSwitch to connect to (localdb)\v11.0 . LightSwitch makes three projects in the solution. If the Client and the Server projects build successfully so the problem is with the third project. Go through these steps:
Right-Click on the third project in the solution
Select Unload Project
Again Right-Click on it and select Edit <yourProjectName>.lsxtproj
Search the SqlExpressInstancename
You will find its value is (localDB)\v11.0 !
Change it to the right SQL Server LocalDB instance name; for more information check the notes below
Now the solution successfully build
--
Note 1: To see which version of SQL Server LocalDb is installed, open cmd and type sqllocaldb.exe v
Note 2: To which instance of LocalDb has been created on the system, open cmd and type sqllocaldb.exe info
Note 3: The instance which is going to be used by LightSwitch must be started: open cmd and type sqllocaldb.exe start
UPDATE: Looking for a better solution I found the correct way to fix this problem. It was a pain for me to follow those 6 steps every time I create a new LightSwitch project. So if you want to fix it once you can do it this way:
In Visual Studio go to Tools->Options
In the Database Tools select the Data Connections
Set your desired SQL Server Instance Name
So no need to set it every time you create a LS project

connecting to sql server, problems

I just build my first web-application in asp.net that connects to a local database.
I got a weird problem.
The connection to the database works if i open the website BEFORE sql server after reboot. I can insert/read from the db from my webpage. But then sql server cant connect to the db. It looks like this then:
If i start sql server before the website then sql server works but the webpage doesnt work, visual studio then gives me this error:
Why are they interfering with each other and what can i do about it?
I use visual studio 2010 and sql server 2008 R2.
did you try to open your connection through server explorer from visual studio 2010 ? everytime you want to display the page in an web browser..just make sure you open the database connection through server explorer, it will work...no matter what was the order of your starting sql server.

Categories

Resources