Cannot connect to a MSSQL Express 2014 Database using VS 2013 Professional (specifically VB) - vb.net

I read another article concerning this problem when getting the file in use message. I went into SQL Management studio and disconnected the database but still no success in connecting. Here's what's happening step by step:
I downloaded SQL Express 2014 and installed it. I created a DB called MyEntertainmentDB, then created a couple of files (Movies and Rating). I added some data to both. I fired up VS and in VB I created a form added various controls including a datagrid. The DB exists in the default location used by MS SQL. I clicked the Smart Tag and the data grid view tasks window appears. I click the choose data source drop down arrow and then add project data source. Database is highlighted and I click next. Dataset is highlighted and I click next. Now I click new connection and select Microsoft SQL Server Database File (Data provider is .NET Framework Data Provider for SQL Server (the only thing in that drop down box)) and I click Continue. Now I'm shown a window that has the data source as Microsoft SQL Server Database File (SqlClient) in the first box and I browse to where my database is located and select it (which is C:\Program Files\Microsoft SQL Server\MSSQL12.SQLEXPRESS\MSSQL\DATA\MyEntertainmentDB.mdf). Everything is going well and I'm using Windows Authentication. I click ok. Now it waits several minutes and I get this message:
The attempt to attach to the database failed with the following message: 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 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 looked in theSQL Server log but nothing was mentioned shedding any light. I could not find any VS log. I checked the windows logs but could not find anything seemingly relevant. I'm at a loss for this problem and am about ready to trash MS SQL server and just go with MS Access 2010 or MySQL. Does anybody see where I'm going wrong? If so, please help, I've tried to be very specific and hope I've provided all info necessary.

First of all you must configure your MSSQL Express Server to respond.
To do that you must open SQL Server Configuration Manager (on Windows 8.1 just go in the upper right corner, hit Search and type: SQL Server Configuration Manager. If you are using Windows 7 you can find it on Start Menu).
On SQL Config Manager you must go to expand SQL Server Network Configuration and you'll see Protocols for (your DB instance). Click on that.
After you click on Protocols for (your DB instance) in the right window you will see Shared Memory, Named Pipes and TCP/IP. Double click on each and set them to Enabled = Yes.
Now your MSSQL Server must listen to standard port 1433. To do this double click on TCP/IP, select IP Addresses (Now you will see IP1 config, IP2 config, etc), scroll down to IPAll and set TCP Dynamic Ports to 0 and TCP Port to 1433.
Now restart your SQL Server Service. If don't know how to this, just reboot your computer. After reboot open command prompt and type netstat -a to see if your MSSQL is listening on port 1433.
Now in Visual Studio when you are connecting to your SQL Server on Server Name type server IP (your IP or 127.0.0.1) or you can select your SQL Server instance from dropdown list without any problems.
You can check this tutorial too: Allow SQL Server Express to accept remote connections

Alright, I finally solved the problem and not in a way people would think. First off, I want to thank everyone who responded with the intelligent answers, but we were off base on this one and I'm not sure why, but your responses ultimately led to my defeating this problem. I've been wrestling with this problem for the last 3 days almost exclusively - I don't like being beaten - and 1 entire night. I've uninstalled and re-installed several times and even got superstitious and waved a chicken bone - lol - at it but nothing worked! I've asked this question on several web sites and finally I went to a link that stated the .msi file was included with MS SQL Server 2012 Management objects I and was hesitant to download as they pertained to the 2012 version. So after tinkering to no avail I downloaded the 2012 CLR Types and Management Objects and looked in the Windows\assemblies folder and still no v 11. But I guess 2012 installation installed them in Program Files (x86)\Microsoft SQL Server\110\SDK\assemblies\Microsoft.SqlServer.Management.Sdk.Sfc.dll v11.0.2100.60. I ran VS 2013 and added the data source. After going through all this problem I'm wondering why Microsoft invents all these places to put things when one would work. Every version of windows from 3 to present has always been totally revised and I wonder for what. Improvements are okay but quit reinventing the wheel. Without your help I might not have ever found the solution and perhaps would have been an oracle or mysql guru or not. Your the men. Thanks all.

Do not connect to mdf, connect to the SQL Server and use MyEntertainmentDB database from there.
The MDF file is locked by the SQL Server for reading/writing data.

Related

Microsoft SQL Server 2012 no database engines

I just installed MS SQL Server 2012 (Express). I went through the whole install process from SQLManagementStudio_x64_ENU.exe (other things were already installed) with checking all the checkboxes, so I thought I had everything necessary.
When I try to connect to .\sqlexpress, I get a message saying "Cannot connect to .\sqlexpress". See below for message detail, I copied it from another question because mine is in Dutch :-)
Cannot connect to .\sqlexpress
I did some research through my friends Google and Stackoverflow, but none of the solutions work.
1. There is nothing in Database Engine -> Local Server Groups -> Register Local Servers (it says "No local servers of type "Database Engine" were found"
2. I cannot restart the services as I only have one "SQL related" service (SQL Server VSS Writer)
3. There are no services listed in Sql Server Configuration Manager -> SQL Server Services
Does anybody know what's wrong? Please let me know if you need additional details.
Thanks, a SQL Server newbie
The SQLManagementStudio_x64_ENU.exe as the name says only contains SQL Server Management Studio, which is the GUI used to manage servers. It does NOT includes any DB engine or anything else but the client tool, so it's normal that you don't have the service installed.
Look at the downloads at the official download website. The file named SQLEXPRADV_x64_ENU.exe or SQLEXPRADV_x86_ENU.exe are the full installs that includes both the client tools and database engine together. It's normally the best possible download I can think of from all the choices.
If I recall correct the file SQLManagementStudio_x64_ENU.exe only contains the management tools and not the server software. You need to download another file (SQLEXPRADV_x64_ENU.exe if you want the complete package with server and reporting services etc.).
See this page for more information
I assumed that you have completed whole installation process without any error.
It may possible that you have installed it with another instance name and possibly because of that you are getting this message.
Following thing you have to check.
Try to access on Same machine where you have installed SQL Server using Management studio.
Start menu or Search for SQL Server Configuration tool. At that tool you will find SQL server instance. name.
Make sure that your instance is running mode.
Which authentication mode you have choose during installation and take proper step during making connection
If above step will not work then please provide more detail.
You need to Download the SQL Server Express Edition with the Advanced Services option.
ADV - with advanced services (reporting services)

Creating a Database Server for home use in SQL Server 2005 Express

I am looking to create a database server that can be used to store data using a VB.net application. When I initially installed SQL Server 2005 Express edition, I believe I installed this using the LocalDB option.
As it stands my application is a simple tool which utilises the Process.Start command under certain situations, depending on user input, to launch Game Servers for use at a gaming LAN I assist in running.
I wish to progress the application by being able to update, delete and query a database created in SQL Server 2005 Express. I understand the use of connection strings etc, however I am wondering if the installation using LocalDB will mean that I cannot connect to the server to process the data I require.
Can I continue to use the LocalDB option and create a Database Server for specific use using my application or is a different installation option required?
Secondly, can someone point me in the right direction of how to create a new Server for this purpose? All of my searches so far have provided results for creating a database only, and not the server.
I have a couple questions about what you are trying to do.
First, why are you installing SQL Server 2005? It was released almost a decade ago.
I would go with 2012 express edition.
http://www.microsoft.com/en-us/download/details.aspx?id=29062
Second, install the management tools. SSMS is a nice GUI to do work in.
Third, If you are spinning up anything other than express, there are licensing costs which are quite high. 9K for standard and 25K for enterprise per socket or such.
Here are the versions and features list from microsoft.
http://technet.microsoft.com/en-us/library/ms144275.aspx
Last but not least, having the express edition on another computer is fine. However, you will have to use a network protocol such as TCP/IP instead of shared memory.
It will take longer to send Tabular Data Stream (TDS) to the other computer versus talking to memory on the same computer.
http://social.msdn.microsoft.com/Forums/sqlserver/en-US/c4f06669-41fd-42e6-b4a9-564cf04ca9f7/how-to-choose-between-shared-memory-named-pipes-tcpip-via?forum=sqlgetstarted
Good luck with your project.
You can use a local instance of SQL Server just fine, if you want to set up a separate server for some reason then you'll need either a 2nd machine on which to install SQL Server, or to spin up a virtual machine. If running Windows 8 (and barring hardware limitations) you have Hyper-V at your fingertips.
This is not a complete answer for you but may give you some things to think about.
First you might want to think about your choice of database. If you don't have a compelling reason for using 2005 you will probably at least want to move to SQL Express 2008.
Second, to answer the part about creating a server... A server is something that serves data. In a general sense a computer configured to be contacted by external machines and respond with data is a server. A web server runs a program like IIS or Apache to respond with web pages. A database server contains a database and allows connections to that database. So as long as you install the database on a computer and configure it to allow external connections, you have your database server.
In MS SQL there are several things that need to be set up to allow a database to accept external connections. One is that the SQL Server Browser service will need to be active. Another is that the database itself will need to be configured to allow external connections (SQL Authentication type probably).
Hope this helps.
Addition:
SQL Remote Connection Configuration
Disclaimer, I don't have SQL Express 2005 installed but I think the settings are found in the same place in 2008. If the info here is not exact to SQL Express 2005, the general terminology used here should be enough to get you headed in the right direction to find the specifics.
While viewing the database in Server Management Studio or Enterprise Manager, right click the database server instance name (the root of the tree) and select properties. There should be a section title Connections and within this section there should be an option "Allow remote connections to this server". Make sure it is checked. The other setting you need in this properties menu is under the security area. There is a radio button for "Windows Authentication Mode" and "SQL Server and Windows Authentication Mode", you want the second that allows both.
The next step you have may be to create a new user, add a password, and connect the user to the database. That will give you the credentials you will use in your database connection string while programming. I usually add new users through the security section of the database then set the User Roles for each database that I need to connect to. It is good practice to limit the permissions to those needed by the application. Typically this is read and write, but sometimes you can get away with just read. The less the better.

Microsoft OLE DB Provider for SQL Server error '80004005'

I have migrated a classic ASP site to a new server and am getting the following error, message.
I have tried different connection strings but none of them work.
I am not even sure if the connection string is the problem
The new server is a Windows 2012 Server, SQL Server 2008 R2 Express machine.
Microsoft OLE DB Provider for SQL Server error '80004005'
[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied.
/scripts/dbcode.asp, line 31
Application("C2M_ConnectionString") = "Provider=SQLNCLI10;Server=(local);Database=mysite_live;Uid=mysitec_Live;Pwd=mypass;"
If it is an Express instance, it is most likely not a default instance, but rather a named instance. So you probably meant:
... "Provider=SQLNCLI10;Server=.\SQLEXPRESS; ...
--- instead of just (local) ---^^^^^^^^^^^^
Otherwise you'll need to show us the server properties in SQL Server Configuration Manager on that machine in order for us to be able to tell you how to correct your connection string.
As Aaron Bertrand mentioned it would be interesting to have a look at your connection properties (In Sql Server configuration check if the following are enabled Name Pipes and TCP/Ip).
Since you're able to connect from SSMS i would ask to check if the Remote connection is allowed on that server Also can you tell is the Sql browser service is running?
here is a link that i keep close to me as a reminder or check list on probable connection issues on SQL Server.
Sql Connection Issues
And lastly can you try as provider "SQLNCLI" instead of "SQLNCLI10"
Step-1: Enabling TCP/IP Protocol
Start >> All Programs >> Microsoft SQL Server >> Configuration Tools >> SQL Server Configuration Manager >> SQL Server Network Configuration >> Protocols for MSSQLSERVER >> right click “TCP/IP” and select “Enable”.
Step-2: change specific machine name in Data Source attributes'value to (local) will resovle the problem ni SQL SERVER 2012.
Try pinging the server in your connection string. The server your application resides on should be able to communicate on the port you specify by credentials. If you are developing locally try specifying "localhost". If the server is clustered or you installed as an instance then you need to specify that instance. Also make sure the server is configured for mixed-mode authentication if using sql credentials.
OR Try
Data Source=localhost;Initial Catalog=DBNAME;Persist Security Info=True;User ID=MyUserName; Password=MyPassword;
It can be a permission issue , Please check is that server is connecting with same configuration detail from SQL management.
other is username / password is wrong.
Here is what I would do:
EDIT: Note that this SO post, a few down, has an interesting method for creating the correct connection string to use.
Open SSMS (Sql Server Management Studio) and copy/paste the
username/password. Don't type them, copy/paste. Verify there isn't
an issue.
Fire up the code (this is next for me b/c this would be the next
easiest thing to do in my case) and step to line 31 to verify that
everything is setup properly. Here is some info on how to do
this. I understand that this may be impossible for you with this
being on production so you might skip this step. If at all possible
though, I'd set this up on my local machine and verify that there is
no issue connecting locally. If I get this error locally, then I
have a better chance at fixing it.
Verify that Provider=SQLNCLI10 is installed on the production
server. I would follow this SO post, probably the answer posted
by gbn.
You have other working websites? Are any of them classic asp? Even
if not, I'd compare the connection string in another site to the one
that you are using here. Make sure there are no obvious differences.
Fire up SQL Server Profiler and start tracing. Connect to the site
and cause the error then go to profiler and see if it gives you an
additional error information.
If all of that fails, I would start going through this.
Sorry I can't just point to something and say, there's the problem!
Good luck!
Have you ever tried SQL Server OLE DB driver connection string:
"Provider=sqloledb;Data Source=(local);Initial Catalog=mysite_live;User Id=mysitec_Live;Password=mypass;"
or ODBC driver:
"Driver={SQL Server};Server=SERVERNAME;Trusted_Connection=no;Database=mysite_live;Uid=mysitec_Live;Pwd=mypass;"
At least this is what I would do if nothing helps. Maybe you will be able to get more useful error information.
Could this be a x86/x64 thing?
The following thread seems to indicate that the (local) alias is a 32-bit alias which fails on 64-bit server:
http://social.msdn.microsoft.com/Forums/en-US/sqldataaccess/thread/c701d510-90e5-4dd0-b14f-ca1d694d6615
(note that the error is exacly what you had)
When you were testing the .udl on the server did you test both x86 and x64?
Following the advice from this blogpost (http://blogs.msdn.com/b/farukcelik/archive/2007/12/31/udl-test-on-a-64-bit-machine.aspx) you could test your
local udl :
in 64-bit by just double clicking it (acts the same as running "C:\Program Files\Common Files\System\Ole DB\oledb32.dll",OpenDSLFile C:\\test.udl
in 32-bit by double running C:\Windows\syswow64\rundll32.exe "C:\Program Files (x86)\Common Files\System\Ole DB\oledb32.dll",OpenDSLFile C:\\test.udl
If you can confirm it's a problem with the alias I'd suggest you create a new one by following the guidelines found here:
http://msdn.microsoft.com/en-us/library/ms190445(v=sql.105).aspx
Have you tried to use the server IP address instead of the "(local)"?
Something like "Server=192.168.1.1;" (clearly you need to use the real IP address of your server)
In case you try to use the server IP address, check in the "SQL-Server configurator" that SQL Server is listening on the IP address you use in your connection. (SQL Server Configurator screenshot)
Other useful thing to check / try:
And check also if the DB is in the default SQL Server instance, or if it is in a named instance.
Do you have checked if the firewall have the TCP/IP rule for opening the port of you SQL Server?
Have you tried to connect to SQL Server using other software that use the TCP/IP connection?
The SQL Server Browser service is disabled by default on installation. I'd recommend that you enable and start it. For more information, see this link and the section titled "Using SQL Server Browser" for an explanation of why this might be your problem.
If you don't wish to enable the service, you can enable TCP/IP protocol (it's disabled by default), specify a static port number, and use 127.0.01,<port number> to identify the server.
In line 31:
cmd.ActiveConnection = Application("C2M_ConnectionString")
How are you instantiating cmd?
Rather than the ConnectionString being wrong, maybe cmd is acting differently in the new environment.
Edited to add:
I see that you've gone from IIS 7 to IIS 8. To run Classic ASP sites on IIS 7 required manual changes to server defaults, such as "allow parent paths." Is it possible that some of the needed tweaks didn't get migrated over?
If you're not running with Option Strict On, you should try that - it often reveals the source of subtle problems like this. (Of course, first you'll be forced to declare all your variables, which is very tedious with finished code.)

Connection failing when I try to process a cube in BIDS

There is probably a simple answer to this question but I do not have much experience with SQL Server/SSAS. I can connect to my local server PCNAME\SQLEXPRESS in SQL Server 2008. On that server I have made a database, some dimension tables, and a fact table that I intend to build a cube from.
I have been following tutorials on the internet on how to build a cube. I can successfully make a data source that connects to PCNAME\SQLEXPRESS, as well as make a data source view from it.
The problem is that after I build the cube, I get A connection cannot be made. Ensure that the server is running. and cannot process the cube. BIDS is displaying the star schema of my tables just fine, recognizes the relationships via foreign keys, etc... so I figured the server was running since it could access all of that data.
Does anyone know why this is happening, and if my server really isn't running can someone tell me how to start it? I am using SQL Server 2008 R2.
Thanks,
Logan
edit: I just tried to change the server name to PCNAME\SQLEXPRESS instead of localhost in the Properties->Deployment option menu. I get A connection cannot be made to redirector. Ensure that 'SQL Browser' is running.
I solved this problem - for people that find this page on Google in the future: when I first installed SQL Server, the SSAS part failed to install. I uninstalled SQL Server and when I reinstalled, I looked deeper into the issue. Apparently one of the services needed to run SSAS has a weird bug where it cannot be started if your Event Log is full. I finished the installation of SQL Server, cleared my Event Log (Administrative Tools -> Event Viewer -> Click Each Log and go to Action -> Clear All Events), and then started the SSAS service in the SQL Configuration Manager.
You can start by going to "Programs->Microsoft SQL Server 2008->Configuration Tools->SQL Server Configuration Manager". Once there, you need to start the services "SQL Server", "SQL Server Analysis Services", and maybe try starting "SQL Server Browser", though I believe that is not necessary.

When trying to access a SQL Server 2008 server in my domain, I get a "server not found or was not accessible" error

When setting up a system that requires a remote computer to access SQL 2008 stored on another computer in the same domain, I'm running into the following error:
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.
When I installed SQL Server, I was sure I set up the system just so. How can I troubleshoot this?
I appreciate this thread is old now and already has an accepted answer, but I found a slightly different solution with regards to this issue that others may find useful. From reading this issue description I found that there were two SQL Server services in the standard Windows Local Services control panel: MSSQLSERVER and SQLEXPRESS (see below).
I found that SQLEXPRESS was running, but MSSQLSERVER was not. So I simply started that service, and I was able to connect to SQL Server again.
A couple of things to try...
check the Configuration settings to ensure that the TCP protocol is enabled.
try accessing the remote server via IP instead of the server name, this has worked for me in the past (oddly).
I'm assuming its running on the default port, if it isnt then you will need to specify the port number after the server-name / ip separated by a comma:
sql-server-name,{port}
Look at the name of the SQL server instance and make sure it is what you are using to connect to it. Also, look at the SQL Server Network Configuration under Configuration Tools. I worte an article about a very similar problem (if not the same) here:
Having had this a few times even with named pipes the first thing I always try is pre-pending the server name before the named instance; so SERVER\namedinstance. You can manually overwrite the dropdown values in the connect . So ideally in the setup it should have a brief tip below the named instance box like Enter SERVER\namedinstance. Although knowing MS if you entered this you'd probably end up with SERVER\SERVER\namedinstance...!
You can also use the browse option (bottom of server dropdown) and if you're lucky it may be in the 2nd tab (Network Servers) - even if it's a local install.
The program you are running needs to be running under an account which has access to the network (and depending on protocol chosen, may need access to the SQL Server by role or whatever). This error indicates that it is not finding the server on the network by name or IP.
The most common case I have seen this is when you have a web app running under a local account which does not have network access attempting to access SQL Server on another machine.
If you have access to the server that SQL Server is running on, you can try:
-Opening SQL Server Configuration Manager
-In the left pane, click 'SQL Server Network Configuration' and then 'Protocols for [instance name, possibly SQLEXPRESS]'
-Right click TCP/IP again and you'll see the port used. Mine was listed under IPAll/TCP Dynamic Port.
-In SQL Server Management studio add the port name to your connection string as follows:
if you were connecting to:
MYSERVER\SQLEXPRESS
the port is specified as
MYSERVER,2071\SQLEXPRESS