Visual Studio error when trying to find my database - asp.net

I am a student learning asp.net and I ran into a problem when trying to reconfigure data sources I created. When I run my web application I am able to edit/add/delete entries that are in my database but when I try to create or reconfigure a datasource it gives me this message:
Database schema could not be retrieved for this connection. Please
make sure the connection settings are correct and that the database is
online.
Could not load file or assembly
‘Microsoft.SqlServer.Management.Sdk.Sfc, Version=10.0.0.0, Culture=
neutral, PublicKey Token=89845dcd8080cc91’ or one of its
dependencies. The system cannot find the file specified.
Now I never changed the place of the database on my computer and I have never deleted it from the originating folder. I went into my 'Sever Explorer' tab and it shows that the database is connected. I right clicked on my database in the data connections list and went to 'Modify Connection...' and ran the 'Test Connection' option and it says the "Test connection succeeded". If my application can edit the database why can't Microsoft Visual Studio find the connection to let me edit the datasource?

As the error indicated that the problem was the system cannot locate the right assembly (SQL Server SDK).
I suspect that the installation of your SQL Server is not a complete or a successful one, or you should have to download some components to provide a successful connection.
Useful links with components that you would consider downloading here or here

Related

ASP.NET MVC Entity Framework application is using wrong SQL connection string

I have an ASP.NET MVC5 web application that was originally created using VS2013 and uses Entity Framework 6 Code First, with data migrations. It has been working fine (in production) for almost a year and has been re-deployed numerous times, from Visual Studio, using Web Deploy.
Today, I opened the solution in VS2015 and redeployed a known working version of the codebase to production without any problems. However, after deployment, the production website suffered from the problems described in this article, which I solved by applying author's the recommended fixes.
After applying these fixes, I now have a new problem: an exception that suggests that the application is trying to access the database using the wrong connection string:
Failed to generate a user instance of SQL Server due to failure in retrieving the user's local application data path. Please make sure the user has a local user profile on the computer. The connection will be closed.
Within the details of the exception page, the cause of the problem is clarified:
The connection string specifies a local Sql Server Express instance using a database location within the application's App_Data directory.
I'm puzzled by this because the application has a dedicated SQL Server instance that is accessed using a regular connection string. I've checked the Web.config generated by Web Deploy and it seems to be intact. It contains a named connection string that correctly references the production SQL Server instance, and the code (which hasn't changed) correctly instantiates an Entity Framework ApplicationContext using the named connection string.
Does anyone have any idea why this application now expects to create its own SQL Server instance or what I can do to debug this problem?
Many thanks for your suggestions,
Tim
A few things you can try before making the web deploy:
Check if the project that contains the connection string declaration (web.config) is setted as the 'startup project'.
Rebuild the solution in release mode.
In the Publish Web wizard, in Settings, expand File Publishing Options and check 'Remove additional files at destination' and 'Exclude files from App_Data folder'

No access to Database File

Last week I created a ASP.NET Web Application project on my machine. It was connecting to a SQL server database file for testing. The database was created in the server explorer part of visual studio and it created a database file with all of the information within it. I was using windows authentication to connect to the database.
Recently my computer has been migrated onto a new netowrk within my company. Now I no longer have access to the database file. The error I am getting is Login failed for user "DOMAIN/USER". I guess this is because the Domain has changed and my computer and the database server are in different domains. However I do not have access to the old domain to add a new login or user with priveladges to access the database.
How can i get arround this?
You cannot get around this, unless an admin is willing to give you a copy of the files from the old drive.
So, you must re-create your database.
Fortunately, if you took proper precautions, this will be easy.
Option 1: If your database is under source control, simply checkout the latest good version of the database.
Option 2: Load the latest backup of the database.

SQL Database error generated during IIS deployment

my asp.net application runs successfully in development server of visual studio. but when i deploy my application in IIS it generates the error as follows
Failed to generate a user instance of SQL Server due to failure in
retrieving the user's local application data path. Please make sure
the user has a local user profile on the computer. The connection will
be closed.
what are the necessary changes that i should do in my application. also guide me how to deploy my database on IIS.
What is your connection string?
More specifically, I am wondering if you are using a .mdf file as your database.
If this is the case, you need to ensure that your web application has write-permissions within the App_Data folder of your website.
It is hard to say exactly without seeing your connection string, but possibly this KB article will help. It relates to SQLExpress and the error you are seeing.
http://support.microsoft.com/kb/2002980

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:
"
"

asp.net SQL Database File Error

We're getting the following error when trying to establish a connection to a database file in the project:
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.
Any ideas on how we can fix it?
Thanks in advance!
http://jeremywadsworth.com/Default.aspx?blogentryid=56 has one possible fix.
http://forums.asp.net/t/1377174.aspx also has further discussion on the topic.
Hope that helps.
--
One more idea. I think I've encountered something like this when using Visual studio to create and access my database. You can detach your database file from visual studio and then directly attach it to your SQL server. I can't remember if the problem manifested in the same way or not but this should get you around the user instance issue. If this doesn't apply let me know and I'll see if i can come up with anything else.
If you are using IIS as the server,then this occurs because the server takes default asp.net database.
In IIS server,create your own application pool and run your app on that instead of using the default pool.
Check the permissions.Give full access control rights.
Also,
go to SQL server configuration>properties. Select local system in the built-in app.. And your new pool should also have local system selected.
This fixed the problem for me. Hope it works for someone here.
PS: If you are trying to making connectivity in Visual studio for android application,then close the visual studio before running it on android as the process wont complete if visual studio is open and will result into error.
SQL Express file attach starts a new 'user instance' SQL Server. This involves a new master/model/msdb/tempdb set of files that are created in the user settings data folder. also the startup of the new 'user instance' can take up to several minutes on extreme cases.
This MSDN article on SQL Server 2005 Express Edition User Instances cover in detail the process and luckly it has some Common Issues and fixes. The most common failure is due to access rights over the user settings copied files. You will usualy get details about the failure in your NT event log (ie. why did the child instance not start).
We got over this by copying the database from my machine to my team-mate's.

Resources