Accessing Server under Windows 7 x64 - sql

we decided to start a new project using the Microsoft SQL Server R2 under Win7. I installed SQLEpress R2 on my system and it was decieded to called it BEACONExpress. At first we could not get it to run, until we had our Domain SysApp come in and set the ownership to my login. Now I was able to use SQL Management Studio to create the Database. I even added some Tables to it. Then I fired up VS 2010 and created a test program. When I try and access the new database, VS returns this error "The file can not be opened because it is being used by another process. Please close all applications that might access this file and try again."
If I attempt to create a new database under App_Data it returns this error. A network-related or instance-specific error occurered while establishing a connection to SQL server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified).
The connectionStrings in Web.config says
<connectionStrings>
<add name="ApplicationServices"
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename= |DataDirectory|aspnetdb.mdf;User Instance=true"
provideName=:System.Data.SqlClient" />
</connectStrings>
I found the database at C:\Program Files\Microsoft SQL Server\MSSQL10_50.BEACONEXPRESS\MSSQL\DATA\BeaconDB.mdf
I tried changing SQLEXPRESS to MSSQL10_50.BEACONEXPRESS but it had no affect. I have been reading here and on other forums trying to determine what is wrong but so far have not found an answer.

Have you verified that the Windows 7 firewall is configured to let you access the SQL Server? I had the same problem when triyng to access a database on my server at home, with Win7 x64.
Also, you should be sure to run the version SQL Server 2008 R2, because if R2 is not installed and all the updates are not installed, it will not work on Win7 x64
Maybe this link can help you:
http://social.msdn.microsoft.com/Forums/en-US/sqlexpress/thread/1bb10896-27ed-4469-81e0-a84f4fba68c9
http://blogs.msdn.com/b/sqlexpress/archive/2005/05/05/415084.aspx

Change your connection string element to
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;Initial Catalog=BeaconDB"
(Where BeaconDB is the name of your database)

Related

SQL server & Visual Studio

I need help with SQL server in visual studio. I can't seem to connect my visual studio with internal SQL server. I had created a database with visual studio earlier and it was working fine but now i'm getting an error saying:
The attempt to attach to the database failed with the following
information: A network-related or instance-specific error occurred
while establishing a connection to SQL Server. The server was not
found or was not accessible. Verify that the instance name is correct
and that SQL Server is configured to allow remote connections.
(provider: SQL Network Interfaces, error: 50 - Local Database Runtime
error occurred. Cannot create an automatic instance. See the Windows
Application event log for error details.
I have tried to create a new database file in a new project but then i get the error:
A network related or instance specific error occurred while
establishing a connection. The server was not found or was not
accessible. (Provider:Named Pipes Provider, error:40- could not open a
connection to SQL server.
I have tried different things but can't seem to get the hang of the problem. I reinstalled visual studio too but that didn't work either. what can i do to get rid of this error and get my database back online?
If you are running Visual Studio on your local machine, you have not any problem with firewalls and enabling of TCP/IP.
Try this four solutions may fix your problem:
SQL Server Express LocalDB add-on, get it from this link.
Make sure that your SQL service is running.
Use SQL Server Authentication.
Make sure you have typed .\sqlexpress in Server name in Add Connection window. You should use a backslash \ as the separator, not a forward slash.

SQL Server 2008 r2 can't login

I am working on Windows Server 2003 using SQL Server 2008 R2 and the .NET Framework 4.
My problem
I can't login to my database from my website although I can login from my Management Studio
I created a login named William.
My connection string is
<add name="TestDbConnectionString"
connectionString="Data Source=(local);Initial Catalog=RESv5;User Id=William;Password=MYPASSWORD;"
providerName="System.Data.SqlClient" />
I got this error:
Login failed for user 'William'
NOTE:
The same username and password I use in the Management Studio and I can login.
Are the website, the SQL Server instance, and SSMS all running on your local machine?
If they are not the same machine, then that is probably the source of the problem: "(local)" on a different machine will mean something different than "(local)" on your own personal laptop.
Try this for the Data Source portion of the name:
Data Source=LocalServerName
... where LocalServerName is the name of the server on which the SQL Server instance is running. If the database is on your machine and the website is elsewhere, use the name of your machine for LocalServerName.
ETA: If you have more than one SQL Server instance running and the one you want is NOT named MSSQLSERVER, you would reference it like this:
Data Source=.\SQLEXPRESS
As marc_s points out, if the instance is called MSSQLSERVER, you can use (local) as you are doing, or
Data Source=.

Cannot login to sql server 2008 R2 after rebooting server

I am using Windows-server-2008 with Microsoft SQL Server 2008.
And there are a lot of questions about this, but nothing on the internet solved it.
The problem is that i can't connect to the my SQL Server 2008 R2 after rebooting my server.
I placed some new memory in my server, and after rebooting my client/server application didn't work anymore because it cannot reach the database.
So i tried to get in SQL Server Management Studio (SSMS), and tried to loggin with Administrator and another user but both do not work.
When i logg in the following message is displayed:
Cannot connect to (local)
A network-related or instance-specific error occurred while establishing a connection
to SQL Server. The server was not found or was not accessible. Verify that the instance
name is correct and that SQL Server is configured to allow remote connections.
(provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
(Microsoft SQL Server, Error: 2)
I Tried a lot of different things like:
Rebooting server
Try to start the server manually from Sql Server Configuration Manager
Named Pipes - Enabled
TCP/IP - Enabled
Tried to create an new system user or database user as described in the following article: Click Here
Can somebody please help me? I am really confused because i need to get this online. Otherwise i have to reinstall the database server but i do not have a back-up. (is there some folder with a back-up of the settings/tables/columns are stored and can be imported from reinstall?
I was having the exact same problem. net start mssqlserver was giving me the blurb about a failed login attempt. The problem was that I had recently changed the password for the administrator account, and the new password didn't get updated in services.
Here's how I fixed it:
First locate SQL Server from the list here:
Right click and select properties, and navigate to the Log On tab:
Then I typed the new password, and like magic I was able to start SQL Server right through the services manager.
I also did this for any other processes which were marked as "stopped" even though Startup Type was marked as "automatic" (namely, SQL Server Agent).
Is it a named instance or default? Also, is this a local instance? (I see the "(local)" but just wanted to make sure.)
Start the sql server services from services.msc and try to connect

Cannot connect to localhost SQL Server 2005

I just installed SQL Server 2005 SP2 on Vista and am attempting to connect to my object explorer in Management Studio. When doing so I get the following error:
Cannot connect to localhost.
A network-related or instance-specific
error occurred while establishing a
connection to SQL Server. The server
was not found or was not accessible.
Verify that the instance name is
correct and that SQL Server is
configured to allow remote
connections. (provider: Named Pipes
Provider, error: 40 - Could not open a
connection to SQL Server) (Microsoft
SQL Server, Error: 2)
I am using the following credentials:
Server type: Database Engine; Server name: localhost; Authentication: Windows Authentication
I am just using SQL Server for a local application. I have tried using 127.0.0.1, my comp name, "." and localhost. I have searched and tried every relevant help topic I could find. I have reinstalled, turned on IIS (just a guess), updated to latest service packs all around, run as admin, etc.
What am I missing here?
JJ
Did you run the User Provisioning Tool for Vista? See KB929907 You may be unable to perform most database operations after you log on to an instance of SQL Server 2005 Express Edition Service Pack 1 on a Windows Vista-based computer
Try using (local)
Also if you have an instance name you can try myComputerName\instanceName
You're missing the instance name. You don't just connect to localhost, but to any of the following (assuming that your machine is called dago and your instance sqlexpress):
localhost\sqlexpress
dago\sqlexpress
.\sqlexpress
I am not using express. It turns out I had a "client" version of SQL Server installed. I didn't even know there was a client version. I ran the full install and added the sa user as Windows Authentication wasn't working for me (next goal). I am connecting via "localhost" (just localhost), so I don't fully understand what the instance suggestion was all about.
Basically the solution was to get the full version installed. My bad. Easy fix.
JJ

Cannot connect to local SQL Server with Management Studio

I'm having an issue with SQL Server, I have 2005 installed on my desktop as well as having SQL Server Management Studio installed..
I've checked and can see "SQL Server (SQLEXPRESS)" started in services.
I've tried to connect to "Local" and "SQLEXPRESS" but both fail to connect.
A network-related or instance-specific
error occurred while establishing a
connection to SQL Server. The
server was not found or was not
accessible. Verify that the instance
name is correct and that SQL Server is
configured to allow remote
connections. (provider: Named Pipes
Provider, error: 40 - Could not open a
connection to SQL Server) (.Net
SqlClient Data Provider)
Anything else I need to do to connect to it??
UPDATE
I seem to be getting a little further along now. Ive managed to connect to my server with SQL Server Management (FYI .\SQLEXPRESS did the trick) but now im having a issue with my connection string in my web.config
Ive im going to connect to this local sql server using windows authentication how do i need to structure it??
Something like this?
<add name="BensBoxing" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=BritBoxing_Alpha;Integrated Security=False;User Instance=True" providerName="System.Data.SqlClient"/>
This produces a error about
Login failed for user ''.
Check the sql log in the LOG directory of your instance - see if anything is going on there. You'll need to stop the service to open the log - or restart and you can read the old one - named with .1 on the end.
With the error you're getting, you need to enable TCP/IP or Named pipes for named connections. Shared memory connection should work, but you seem to not be using that. Are you trying to connect through SSMS?
In my log I see entries like this...
Server local connection provider is ready to accept connection on [\\.\pipe\mssql$sqlexpress\sql\query ]
As the comments said, .\SQLEXPRESS should work. Also worstationName\SQLEXPRESS will work.
Same as matt said. The "SQL Server(SQLEXPRESS)" was stopped. Enabled it by opening Control Panel > Administrative Tools > Services, right-clicking on the "SQL Server(SQLEXPRESS)" service and selecting "Start" from the available options.
Could connect fine after that.
I was having this problem on a Windows 7 (64 bit) after a power outage. The SQLEXPRESS service was not started even though is status was set to 'Automatic' and the mahine had been rebooted several times. Had to start the service manually.
Try to see, if the service "SQL Server (MSSQLSERVER)" it's started, this solved my problem.
Open Sql server 2014 Configuration Manager.
Click Sql server services and start the sql server service if it is stopped
Then click Check SQL server Network Configuration for TCP/IP Enabled
then restart the sql server management studio (SSMS)
and connect your local database engine