Creating Database in Visual Studio 2015 - sql-server

I am trying to create a database in Visual Studio 2015 MVC setup. When I create a new file in the "App_Data" folder and select SQL Server Database, a popup comes up that says the following:
"Connections to SQL Server database files (.mdf) require LocalDB or
SQL Server Express to be installed and running on the local computer.
You may need to modify the setup and ensure Microsoft SQL Server Data
Tools is selected."
I have already installed SQL Express in my computer. But Visual Studio still shows the same popup. Can anyone please give me a step by step instruction on how to create a DB through Visual Studio 2015?
(My thought was if I clicked on new file->SQL server Database, then a popup would launch allowing me to input my data and name it. But I obviously am unable to do that).

Make sure that SQL Server is up and running. Open up SQL Server Management Studios (installed with SQL Server) and try and connect to the instance that you created (should be the same as your machine name). If it fails to connect, SQL Server might not be running.
To turn it on, open SQL Server Configuration Manager (just do a search and it'll show up), go to SQL Server Services, and turn on the database engine. You should then be able to connect to the database.

Related

Local server in SQL Server 2012 Management Studio

I've installed Microsoft SQL Server 2012 Management Studio today and now I'm trying to connect to server. As far as I know there should be default local server that would allow me to create a database in it. Unfortunately, my list of servers is empty and I cannot connect to anything. I've read tutorials and tried everything, even reinstalling all the Microsoft SQL Package. How can I fix this problem and find/create my local server?
Ok, I've read that there might be a problem with connecting to database even if whole microsoft package gives me LocalDB. I had to install Visual Studio, then clicked View -> SQL Server Project Explorer. Right click at 'SQL Server', I added new database and then entered its name. Now I can connect with my own server by typing '(localdb)\v11.0' in management studio.

How to Open a Database from Visual Studio Server Explorer in SQL Server?

Question Background
I have a created a database in Visual Studio under the Server Explorer tab. This is fine but I would like to be able to open this database in SQL Server Management Studio (SQL Server 2008 in this case). I can't see the database under the database list in SQL.
How can I open the database I've created in Visual Studio in SQL Server?
The following diagrams show the issues:
The MainDB.mdf database in VS:
SQL Server 2008 Management Studio. The database MainDB database is not showing:
You are connecting to two different instances. From Visual Studio, the default instance is either localhost\SQLExpress or just localhost (or just your computer name). From SQL Server Management Studio I can see that you specified something else. From the "Connect to Server" window in SQL Management Studio, choose one of the instances I mentioned above. Or alternatively, from Visual Studio, right click on "Data Connections" --> "Add Connection...", and then specify the same instance name you used to connect using SQL Server Management Studio.
Since you are using Visual Studio 2012, here is something that changed - VS 2012 uses a localDB instance whenever you create a database for use within your application. So you have 2 options:
1. There is a new window called the SQL Server Object Explorer that you can use to work with your LocalDB. It provides a view of your database objects that’s similar to SQL Server Management Studio. You can access it from the view menu.
2. If you still want to use SSMS, you can access it by putting (localdb)\v11.0 in server name. More about this here.
It should show directly in SQL Server, Unless your are using different credentials for connection. (credentials means Server Name & User)
Create new DB
http://i.stack.imgur.com/FEmMB.png
Explore in sql
http://i.stack.imgur.com/VxgiV.png
Can you let us know are they both same ?
You can also try 'Browse in sql server object explorer' by right clicking DB name in Visual studio

Connection to Remote SQL Server 2012 from Visual Studio 2013

There is a weird problem that I am facing. I have Visual Studio 2013 and SQL Server 2012 Management Studio. A few days back I was easily able to connect to the remote database that resides on another PC on the network with SQL Server Management Studio installed through the following procedure:
Goto Server explorer
Connect to the database
Browse the server name. It came as HO-IT-WS-08\SQL2012. Select it.
Browse the database names. Select the relevant database
The test connection used to be successful. However now, doing the same procedure my visual studio crashes once i perform the 4th step and restarts. It is like this. I select the server name browse the databases and the visual studio crashes restarting. I checked all the things but am not able to figure out the issue. Kindly help me!
Did you try entering server name without browsing it?
When you go for browsing, VS queries the network for the Sql Server browser services and "hangs" until it receives response.
Maybe the SqlServer browser has been disabled? Go to SqlServer Configuration Manager, and check for SqlServer Services / Sql Server Browser.

Visual studio 2012 neither able to add database file (.mdf) nor create aspnetdb with Sql Server 2012 x64

I'm using VS Pro 2012 and SQl Server 2012 64 bit developer edition.
Here is a quick view of my SQl configuration and the errors when taking ASP.NET configuration in VS 2012 and when adding a new database.mdf file. Notice that I can connect to SQL server database created with aspnet_regsql tool from Server browser window.
I've tried most of the answers for similar questions I found.
There is a problem with your selected data store. This can be caused
by an invalid server name or credentials, or by insufficient
permission. It can also be caused by the role manager feature not
being enabled. Click the button below to be redirected to a page where
you can choose a new data store.
The following message may help in diagnosing the problem: Unable to
connect to SQL Server database.
Please help me solve the problem with VS 2012. I've tried it with both win7 & win8 installations, but all in vain.
The connection string uses default Data Source=.; and I can connect to default instance . from SQL server Management Studio.

Importing a MDF file into SQL Server 2008?

I have inherited a VB.net web app that I'm making some changes on. I'm perfectly capable with the programming side (VB and MSSQL) but I'm getting lost with the tools. I was given a zip file of the code and everything. I opened the sln file in Visual Studio 2005 and it worked fairly easily with little modification.
Running the app works perfectly. Problem is, I need to write some new SPs so need the database admin. SQL Server 2008 Express is installed but it doesn't see any database and I have no idea how to import it.
I have a folder App_Data in the project with the file ASPNETDB.MDF. Opening this in VS gived the error:
This server version is not supported. You must have Microsoft SQL Server 2005 Beta 2 or later.
Any ideas where to go from here?
You need to get Sql Server Management Studio. From there you should be able to connect to the instance of Sql Server Express running on your system and tell it to attach to the .mdf file. This will allow you to use that database from withing sql server and management studio, and you will be able to add your stored procedure. Just remember to detach again when you're done, or you won't be able to use the mdf file as you expect from your app.
Visual Studio uses SMO 2005 to connec to to SQL. The SMO 2005 will not connect to SQL 2008 by design. You need to either upgrade VS to VS 2008, or downgrade Express to Express 2005.
You can't attach mdf file made in SQL Server 2005 to a SQL Server 2008 instance. What you need is to install SQL Server 2005 Express, attach this file, backup database, then restore it on 2008 Server instance and detach the database. You will get properly created for 2008 Server mdf.

Resources