SQL Server 2012 connection string: can no longer find Server? - asp.net

I just installed VS2012 pro RC and SQL server Express 2012. I go to run my app and I get this error:
The Data Source value in the connection sting specifies an instance of SQL Server
that is not installed. To resolve this issue, you can either choose to install
the matching instance of SQL Server or modify the Data Source value in the
connection string.
I used VS2012 Developer preview for a long time and it used to work just fine. This is the connection string that's in the web.config file:
<add name="MySiteDBConnectionString"
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\MySiteDB.mdf;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient"/>
When I go to Management Studio, I get the error message below. When I go to browse for servers, the list is empty.
Where's the problem and how do I solve it?
Thanks.

You need to make sure the SQL Server service is running. Visual Studio might be spinning it up for you when you establish a connection using web.config and that silly AttachDbFileName feature. Check your Services Control Panel applet and make sure that SQL Server (SQLEXPRESS) is running. If it isn't running, start it.
While you're there, it can't hurt to make sure the SQL Browser service is running.
It also can't hurt to use the proper case. If the instance is called SQLEXPRESS then don't call it SqlExpress or SQLExpress. I've never heard of this breaking connectivity, but be consistent. You might also try other variations just in case:
(local)\SQLEXPRESS
localhost\SQLEXPRESS
127.0.0.1\SQLEXPRESS
Your_Computer_Name\SQLEXPRESS
You should also verify what connection protocols are enabled for this instance. Go to Start > Programs > SQL Server > Configuration Tools > Configuration Manager, expand SQL Server Network Configuration, and highlight Protocols for SQLEXPRESS - on the right you should see Shared Memory, Named Pipes, TCP/IP. Which of these are enabled?
EDIT
You should download SQL Server 2012 Express from here. Install it. Then create a database. Point Visual Studio at that database. Stop, and I really mean STOP, using the User Instance and AttachDbFileName features. These things are supposed to make development easier but at the end of the day they do little but make development a royal pain in the rear.
Another option is to use SqlLocalDb for local development. Last month I wrote a thorough "Getting Started" tutorial that may help.

Related

The 'msolap' provider is not registered on the local machine

tried looking at other examples on this and am a bit confused. I have 2 web servers that are load balanced and a sql server box (sql 2012). my cube is created on the sql server box (i see it in management studio). when i try to access via my asp.net page i receive the above error.
now, i see the msolap110.dll in C:\Program Files (x86)\Microsoft Analysis Services\AS OLEDB\110 on the sql box. do i need to do something permission wise with the dll or something? do i need to install analysis services on the web server? is there a specific port or something (doubtful as sql is running fine).
connection string is as follows:
"Provider=msolap;Data Source=;Initial Catalog=AutoOLAPAW;Cube Name=SampleCube;"
going to try to force to use MSOLAP.5 but waiting on a republish from our security/deployment group.
this all works fine in dev but my (more secured/stripped down) prod/qa is where i'm seeing the issue. using iis7 on both.
If you are using ADOMD.NET then either set CopyLocal=True on that reference on your ASP.NET source code so Microsoft.AnalysisServices.AdomdClient is deployed with the web app... Or install SQL_AS_ADOMD.msi from:
https://www.microsoft.com/en-us/download/details.aspx?id=49999
If you are using OLEDB then install SQL_AS_OLEDB.msi from that same link.
If you don’t want the SQL2012 version but want the latest then install from here and use Provider=MSOLAP in the connection string (instead of a number like MSOLAP.5).

Establishing connection to SQL Server Error

I opened my web project today and for some reason I could not gain access to my database files. I get the following exception whenever I try to add, edit or refresh my database:
A network related instance specific error occurred while establishing
a connection to SQL Server. The Server was not found or is was not
accessible. Verify that the instance name is correct and that SQL
Server is configured to allow remote connections.
I took a look at my connection string for any spelling errors and deleted my database and replaced it in the folder I had it in. I can't seem to find a fix for this so any help would be a appreciated. I am using Visual studio 2008 for this web project.
This sounds like the same problem that I had myself awhile back. My problem was that my SQL service pack 1 did not install properly so I had to install Microsoft SQL Server System CLR Types, Microsoft SQL Server 2008 Management Objects and Microsoft SQL Server 2008 Native Client. After that I could create new SQLdatasources but I could not edit the ones I had previously before my problem. I had to restart my computer in safe mode and delete my SQLEXPRESS folder then recreate the database connection in visual studios. When I finished that everything worked fine.
This is the site I got those downloads, http://blogs.cametoofar.com/post/cannot-load-file-or-assembly-microsoftsqlservermanagementsdksfc.aspx

Sql Server Error 26 Local

(The database is on my PC)
My database worked just fine for a month, and then this error came. It is not related to a specific file, nor a specific project (Even if I'll create a new website and try to add a new database file, this error will pop)
I guess it happens because the sql server is not running on my PC, and it is true that I don't see any sql related process running.
How the I fix it?
P.S. I know this error has a lot of threads on the internet and even here in SO. But most of them solve the problem for a complicated, secured connection with a remote server. All I want is to create a new empty ASP.NET website and add a new .mdf file for it on my PC.
It may be related with the SQL Service authentication which you have to verify from the control panel->Administrative tools->Services. Locate SQL Server(Express) Try changing the Log on As Network Service instead of local system.
that is a error Locating Server or Instance.
Try connecting by IP.
Have you disabled SQL Server browser?
I was facing something similar so I will share how I solved it, it might work for you or not, but here are my 2 cents.
My environment: Windows 10 ( upgraded from windows 8 in which SQL Server was working fine)
SQL Server 2014 Express
Solution: I Opened the services program, and found the SQL Server services, I saw that all of of them were up except by one which was disabled, the "SQL Server Agent", I enabled it and was able to connect to my DB instance.
Hope it helps
Regards

Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed

I've attempted to add a "service based data base" (.mdf) to a project in an asp .net application. From there I've proceeded attempted to create an entity framework model file (.edmx).
When doing so I get the error:
An error occurred while connecting to the database. The database might be unavailable. An exception of type 'System.Data.SqlClient.SqlException' occurred. The error message is: 'Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed.'.
I've got SQL Server 2008 R2 Express edition installed on my machine.
Any ideas would be most appreciated.
I have got the same error, it's fixed after the following change.
Deleting the folder C:\Users\User\AppData\Local\Microsoft\Microsoft SQL Server Data worked for me in Windows 7. Have to restart VS after deleting the folder.
See this answer, which might work for you.
Based on your connection string, you might need to add "User Instance" attribute to it.
I had this exact same problem with a C# Console App that was utilizing an .mdf file.
The issue disappeared once I granted NETWORK SERVICE full access to my root-level Visual Studio project directory (and sub directories).
Solution Details: Problems with SQL Server Express user instancing and ASP.net Web Application Projects
I was facing same issue in VS 2019. if anyone still facing same issue then please make sure you have/do following things:
1. you should have Sql server Express installed on your m/c
2. should have SSDT installed in VS (in VS 2019- name sure to check this component while installing) for previous version; i guess you have to add this externally
3. add 'User Instance = True' to your connection string
and one more thing and I think its optional - open VS and SQL in administrative mode
If you build your own custom membership solution, do not forget to add this line to your Web.config's AppSettings section:
<add key="enableSimpleMembership" value="false" />
otherwise you'll get the same error message
I have same issue, but it only happens when I reboot the PC and run the application from a fresh start. If I then attempt to re-start the application (wo rebooting), it does connect and I have full access to the database. I tried to change the connection string with a long timeout (600, 6000, 60000), but that made no difference. Here is the connection string:
"
"

Minimum requirements to use AspNetSqlMembershipProvider

I'm using an AspNetSqlMembershipProvider for my application.
On my development machine I recently deinstalled SQL Server 2005 Express and Management Studio Express so that I could install the full version of Management Studio. I chose not to install SQL Server 2005 because, well, I don't want to have unnecessary things running on my machine.
Now whenever my code attempts to do anything that relates to authentication I get an error of:
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: 26 - Error Locating Server/Instance Specified)
So, what is the minimum amount of SQL Server I have to install in order for this to work?
You could get away without having any SQL Server instances installed, especially if all you're using it for is Membership, Roles and the default Profiles.
The default connection string often looks like this:
<connectionStrings>
<add name="LocalSqlServer"
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"
providerName="System.Data.SqlClient"/>
</connectionStrings>
If you change your SQL connection string, to match the value of "connectionString" above, that will force ASP.NET to generate the standard ASP.NET database for you withing the "App_Data" folder of your site - the keep part is "AttachDBFilename" which tells it to open the mdf file directly rather than attach to a SQL instance.
However, you might have some difficulty connecting to that file with SQL Management Studio.
You'll probably have to change the connection string once you move the site off development and into production, to point to a full instance of SQL if you so wish, rather than stick with the file based version.
Alternatively, what I tend do is have SQL Server installed (Express or otherwise), but the services stopped unless I'm actually using them. Then I just start them up when I'm developing.
Also you can have the Express version of SQL Server installed on the same machine as theh the full version SQL Management Studio without any problems.

Resources