I'm learning ASP.Net and attempted to create a default ASP.Net project in VS2010 for the first time using VB.Net for the programming language.
After running the ASP.Net project, a default web page was displayed in a browser window. I tried to click on the LogIn link on the displayed web page and this error is displayed:
The user instance login flag is not supported on this version of SQL Server
We are using SQL Server 2012 Enterprise. We also have IIS7 installed in Window7. We have SQL Server, Visual Studio 2010 and IIS7 installed on the same computer.
I'm assuming a new database needs to be created but I don't know the details on what this database looks like or if there is a script that can be run that creates it.
All help will be appreciated.
The connection string for that application probably has User Instance=true set, which is only valid for SQL Server Express. You should remove that part from the connection string.
SQL Server 2012 no longer has user instances, instead opting for LocalDB.
Found out how to do it.
I changed the connection string to look like this:
connectionString="data source=.\SQLSERVER; Initial Catalog=aspnetdb;Integrated Security=True;"
The problem was being caused by:
AttachDBFilename=
It threw me off because I was assuming VS2010 would create the correct connection string.
Related
I have a web site that works as it should on our company intranet, which I am now trying to deploy on a hosted web server. Unfortunately when a user clicks Log In it crashes with:-
Server Error in '/' Application. Could not find stored procedure 'dbo.aspnet_CheckSchemaVersion'.
If I go on to the remote server's desktop, log in to Management Studio with the username and password in the site's webconfig.cfg file, then I can open the aspnetdb database, and execute dbo.aspnet_CheckSchemaVersion without any error messages or access issues.
I have read numerous other postings on this error message and none of the suggestions have helped, but I am new to web site administration and may be missing something obvious.
The web site is coded in VB.NET, and compiled with Visual Studio 2012. Third party tools used are Fusion Charts and AJAX Calendar Extender. The .NET Framework version is 4.5.
The remote server runs Windows Web Server 2008 R2 with IIS version 7.
The database server is a named instance of SQL Server Express 2008 R2.
There are five users defined in the aspnet_Users table, which I added using the .NET Users applet within IIS. I can no longer use the user management tools in IIS because I had to upgrade the site's application pool to .NET 4.0 which does not support them. However I can see the users are there.
There are no Roles defined in aspnetdb.
Does anyone have any ideas what I could be missing?
Try recreating the ASP.net procedures with something like:
aspnet_regsql.exe -S DBServerName -U DBLogin -P DBPassword -A all -d DBName
Just so this question is no longer "unanswered", I will echo Aaron Bertrand's comment, which the questioner said was the correct answer:
Does your connection string specify the database? If not, then perhaps the application is trying to execute that stored procedure in the login's default database, not the aspnet database. – Aaron Bertrand Feb 17 at 14:44
Thanks very much that was it. I changed the "Initial Catalog" in the connection string to aspnetdb, now I can log in. – user3319440 Feb 17 at 16:30
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.
I'm developing an ASP.NET web app that needs to access an SQL Server database. The server the app needs to run on is running Windows Server 2000, SQL server 2000, IIS6, and .NET 2.0.
If I run the web app on my machine with Visual Web Developer 2010 with the testing webserver in Visual studio, but accessing the database on the actual web server, it works fine. However, If I put this app on the actual webserver, and try to access it through the browser, I get a permissions errors saying I don't have access to those tables.
There are two tables my app needs to access. On one of them I changed the permissions with SQL Management Studio to allow the public group select permissions, and that solved the problem. On the other table (very large table) I tried to do the same, but got an error saying it timed out waiting to get a lock on the table. Is there a way to change this timeout or another way to change the permissions?
I don't believe I should even have to change the permissions though, because there are classic ASP apps on that server that access the very same tables. I think the issue is the user that is being used to access the tables. If I can access the tables running the web app from my machine, and classic ASP apps on the server can access them, but my ASP.NET app can't, my ASP.NET app must be using a different user account. How can I check this and make the necessary changes?
Regarding your permission error, it's probably because on your machine the app is accessing the database with your permissions, with windows integrated login.
Normally, a web application is supposed to access a database using a technical user, that is specified in the web.config file, in the connection strings section. It's something like
<configuration>
<connectionStrings>
<add name="myConnsStr" connectionString="server=myserver.example.com;database=mydatabase;uid=tech_account;pwd=tech_account_password" providerName="System.Data.SqlClient" />
</connectionStrings>
...
</configuration>
How does yours look like?
For the other one, yes, do the permission change in T-SQL. If you are not sure how to do that, do the change in the designer, then before clicking OK, use the Script button in the header area. Script the change to the clipboard and then try to run in a new query window. You can play with the query timeouts in the options dialog.
You could try setting the lock timeout to -1 (meaning it'll never timeout)
SET LOCK_TIMEOUT -1
GO
And you can also try adding the permissions using a query
sp_addrolemember #rolename = 'db_datareader', #membername = 'YourAspApp'
You can also try to change your asp.net user in the asp.net connection string to a user which already has selecting privileges.
Let me know if any of that worked, it's a good place to start with =)
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:
"
"
I just created my first ASP.NET Version 4 app using Visual Studio 2010 and SQL Express 2008.
I copied the files to IIS and run the default.asp. This loads the programs main menu. So far so good.
When I open the read webform and do a read of my database I get the following Error:
Server Error in '/Diary' Application.
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.
Any idea how to fix this error?
Did you look at support articile for the very issue.
Or even this