Problem with creating .MDF file from Visual Studio 2010 - sql-server

I am trying to create a small wpf application by using mdf.
The problem is that when I am trying to add new service-based database (.mdf) I am getting the error "Connection to SQL Server database files (.mdf) require SQL Server 2005 Express or SQL Server 2008 Express to be installed and running on the local computer. The current version of SQL Server Express can be downloaded at the following url (link)".
The SQL Server 2008 is already been installed.
What am I doing wrong?

Check to make sure the SQLExpress service is running.
From a command prompt:
sc query mssql$sqlexpress
If the state returned is "1 STOPPED", then start the service with
sc start mssql$sqlexpress

Make sure the services are running on your box. The important ones will be SQL Server, and SQL Server Agent.

Related

Connect to your sql server without credentials

I created a project in visual studio and I want to use SQL Server Management Studio to see database. What should be the server name?
On connecting to sql server, it gives error:
I tried finding server name using cmd so the result was:
Note:
My sql server configuration manager doesn't contain any sql server services. I was using sql server 2012 so now I downloaded sql server 2017 but same, so services are shown.
How can I connect to sql server?
You will not be able to connect to the SQL server if the SQL Server service is not running. Once you have verified your service is running, you can use the option in the Server name to select your SQL Server Name.
Irfan.
You can connect to SQLServer with two ways:
Usually you run SQLServer instance as service and connect using server credentionals
Sqlexpress "embedded" style - connect to mdf/mdb-file. Behind the scenes it will start localdb service and attach db-file.
First way is recommended in most cases.
Run services.msc and look for sqlserver instances. If they are down - start one. If they are notexistent - rerun installation and check options.

Unable to login to sql server

I dont know much about sql server.
I have just re-installed windows 7 on my laptop. After that I installed Visual Studio 2012 Express Edition. I also Installed SQL Server Management Studio 2008 R2.
Now when I try to log in to sql server management studio by using server name as . or (local) or .\SQLEXPRESS or PC-Name\SQLEXPRESS and using Windows Authentication I get the error as below.
Please dont mark this question as negative as I have searched on google for last 4 hours but did not understand the problem.
Update:
There are many reasons that may cautioning the problem:
SQL Server is not running
SQL Server is not properly configured
You try to connect with a worng instance Name
You can try the following:
Go to Mycomputer->Rigt Click->Manage->Application and Services
And from there check that SQL Server Express is running
2.From there also, gCheck the Instance name of your SQL Express and be sure when you log on to Management Studio you Provide the same Instance name
Confirm that the service is installed and running. Under Computer Management, drill-down into Services and Applications -> Services.
There should be a service named "SQL Server (SQLEXPRESS)". Try a restart or start of the service.
If any other instance of SQL Server is installed it will be listed - try connecting to LOCALHOST(whatever the instance is listed as) to verify the installation is functional.
UPDATED following further information from comments:
You may have only installed the client tools (management studio), and have not installed the database service. Ensure you have the correct installer which includes the database services engine.
First check that the SQL Server parameters are set accordingly.
Go to Start -
All Programs — Microsoft SQL Server 2008 R2 — Configuration tools —
SQL Server Configuration Manager
Under SQL Server Services, make sure that the instance is running :
SQL Server ()
SQL Server Browser
Under SQL Server Network Configuration - Protocols for (), these are enabled:
TCP/IP
Named Pipes
Do the same under SQL Native Client 10.0 under Client Protocols

SQLExpress instance seems to be absent

I am trying to connect to a SQL Server Express instance on my laptop; I have SQL Server 2008 installed in my system, but when I try to put the instance (local)/SQLEXPRESS or Jashobanta-PC/SQLEXPRESS in my system, I am not able to connect to it. It is appearing that it is not even present in my system.
I am getting the following error :-
A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online..
I have tried using the SQLCMD command tool also for this, but the result is same:-
sqlcmd -E -S .\SQLEXPRESS
Here also the same error is appearing.
Is there any chance that SQLEXPRESS is not installed in my system? But as MVC Code First uses SQL Server Express, I need it. When I use code first, then the files are created fine, but how it is connecting, where it is creating the database, it is not known.
Any suggestions will be helpful.
Thanks in advance
Jashobanta
I had a similar issue to this, so for google purposes I'll list my result.
My take on the problem was that I had a SQL2008 Express instance, that had 'gone dark' because I'd installed a full instance of SQL2008R2 and/or SQL Express 2012. My guess is that one or the other of these turns off the out-of-date express instance as a security risk.
These instances were installed as fresh instance names, but somewhere along the way my (local)\SQLEXPRESS instance was disabled.
Using this link I used the SQL2008R2 installer to upgrade the SQLEXPRESS instance that the installer detected.
Once the SQLEXPRESS instance was upgraded to 2008R2 it was happily re-enabled and accessible at (local)\SQLEXPRESS, with all my previous databases inside it.
I have a same problem just now. What you need to do to resolve the problem is to install SQL Server 2008 Express edition.
You can do this by searching "SQL Express" from Web Platform Installer and install "SQL Server 2008 Express with Advanced Series" and "SQL Server 2008 Express with Tools".
Or
Download from this url and install.
http://www.microsoft.com/en-us/download/details.aspx?id=1695
.\SQLEXPRESS is SQL Express for SQL Server 2008 while
(LocalDB)\v11.0 is SQL Express for SQL Server 2012 / 14

No services listed when SQL Server Express 2008 R2 Installed on local computer

I cannot get my local computer to run SQL Server. I looked in the SQL Server configuration manager and noticed that there are no SQL Server Services listed. That can't be right. I also noticed that There are two Managers listed in the SysWOW64 folder (I'm running Win7): SQLServerManager10.msc and SQLServerManager.msc. Neither show any services at all. When trying to connect via SSMSE, I get the standard:
A network related or instance specific error occurred while establishing a
connection to SQL server...
I haven't installed a prior version, but did try to uninstall and reinstall using the Web platform installer from Microsoft. Any suggestions?
Thanks
I had the same problem and as Brian said, I was missing SQL Server Express. So I download SQL Server 2008 R2 Express and I installed it. now everything works fine.
Note that I thought I already installed it when I installed SQL Management Studio R2. Now, be aware that when installing SQL Management Studio R2, you are not installing SQL Server and you won't get any SQL Server Services in your Sql Server Configuration Manager -> SQL Server Services. You also need to download and install SQL Server Express.
Is SQL Server listed in services? (Start->Run->Services.msc)
If so, is it running?
That is an instance error, meaning you cannot connect to the instance. Most likely there is no instance installed on this machine. Meaning your not connecting correctly to the instance. Connect to the database engine again and check the server name and make sure your connecting to the correct server name or the local host, depending if this is a local machine or if this is on a server. Go back through setup and see if there are any features that didn't get installed. Try that and see if it works. If not then reinstall SQL Server and make sure all folders are removed and nothing is left behind before you reinstall.

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