I try to use Web Site Administration Tool to set up Roles in my website.
I receive an error testing "AspNetSqlProvider"
"Could not establish a connection to the database.
If you have not yet created the SQL Server database, exit the Web Site Administration tool, use the aspnet_regsql command-line utility to create and configure the database, and then return to this tool to set the provider."
I used aspnet_regsql command-line utility successfully and in Visual Studio I can see in Server Explorer the database and all the tables.
WebConf is empty
What the problem could be? thanks
I've hade the same problem as you before. If you check your web.config you need something like this:
<connectionStrings>
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer"
connectionString='YOUR CONNECTIONSTRING HERE'
providerName="System.Data.SqlClient"/>
</connectionStrings>
The important part was the remove LocalSqlServer and that the new connectionString was named the same. Hope this helps.
If you have correctly set up the web.config and still get this error I almost guarantee it is because you have an open connection to it in visual studio which blocks the connection.
Solution:
In visual studio right click the connection to the database (which probably has a 'connected' icon) and click 'close connection'
Reattempt to access the membership administration tool.
et voila
Related
So I'm in the process of making the configurations for my site on Plesk Web Host Edition but unfortunately I have an issue of accessing the database through my website.
I have noted the following:
1. I can access the Database through SQL Server Management Studio (SSMS) without any issues but one important thing to mention is that when I try to make my DB user as the owner of the database I get the following error:
Cannot alter the role 'db_owner', because it does not exist or you do not have permission. In other words, I'm not the owner of the database and I can't alter anything in it! although that I have created the database and the DB user through Plesk Panel.
2. I configured the web.config as follows:
<add name="xxxConnectionString" connectionString="data source=127.0.0.1\SQLEXPRESS;server=127.0.0.1;database=xxxx.mdf;Uid=xxx;pwd=xxxx" />
3. When accessing the website I get the following error:
Cannot open database "xxx.mdf" requested by the login. The login failed.
Login failed for user 'xxx'
I contacted the support of the hosting provider but it's been almost 4 days now without any reply. I'm really hoping of finding the answer with you guys.
Thanks in advance
I was able to find a solution for the ConnectionString issue. Below is the connection that I used to fix the issue:
<add name="CarRentalConnectionString" connectionString="Data Source=localhost;Initial Catalog=DATABASENAME;Integrated Security=false;User ID=USERNAME;Password=PASSWORD" />
So if I create a new MVC project with basic log in template, there should be somewhere a database which contains all the user login information. There's even the default connection string which points to it.
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-MyProjectName-20140521042155.mdf;Initial Catalog=aspnet-MyProjectName-20140521042155;Integrated Security=True" providerName="System.Data.SqlClient" />
How ever, when exploring the project folder I cannot find it. I also tried to turn on "show all files" option in the solution explorer.
Sql Server Management Studio can be used to connect to the local db server. You can also use visual studio server explorer.
I want to setup login roles for my application.
When I go to the ASP.NET Configuration Tool and Click on the Provider Tab,
I select: Select a single provider for all site management data
I get this: AspNetSqlProvider
When I click on the test hyperlink, I get this message:
Could not establish a connection to the database.
If you have not yet created the SQL Server database, exit the Web Site Administration tool, use the aspnet_regsql command-line utility to create and configure the database, and then return to this tool to set the provider.
1) I created a ASPNETDB.MDF file in the APP_Data Folder
2) Ran the aspnet_regsql.exe tool that created the database ASPNETDB in my SQL Server
3) Edited the maching.config file for
<connectionStrings>
<add name="LocalSqlServer" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DIRECTORY|\App_Data\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/>
</connectionStrings>
In DIRECTORY, I replaced DIRECTORY with the actual path: C:\Documents and Settings\Owner\My Documents\Visual Studio 2010\WebSites\myProject
Don't know what else I am missing to get the ASP.NET Configuration Tool to work
Thanks in advance for any help!
Solved the issue :
1) Created a new website and copied the database it created in the app_data folder to myproject
app_data folder.
2) Copied the differences in the webconfig sections from the website to myproject.
Configuration tool now works correctly.
I am using Visual Studio 2010 in which want to create a local DB file in my project.
When I register using the pre-built login, Visual Studio should create the DB file, but instead it shows a message box saying
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.
When i try to add it manually it shows the same message.
What can be done to resolve this issue?
Check your connection string on your App.Config file if its Correct.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="DB" connectionString="Data Source=MyPC\SQLEXPRESS;Initial Catalog=IIQR;Integrated Security=True"providerName="System.Data.SqlClient"/>
</connectionStrings>
</configuration>
There are two solutions for this
1. Delete the following directory:
C:\Documents and Settings\username\Local Settings\Application Data\Microsoft\Microsoft SQL Server Data\SQLEXPRESS
2.. If that didn't work, then go to Control Panel -> Administrative Tools -> Services, right click on SQL Server (SQLEXPRESS) and go to Properties. Go to the Log On tab and then select Local System account as the option.
The first option (deleting SQLEXPRESS) did not work for me but the second one did.
Can anyone help?
I created a DB under APP_Data using ADD ITEM and choosing SQL Server DB and sure enough its there. I can even double click it and it opens up in VS 2010 in the Server Explorer tab.
The connection that i have configured in my web.config is the following
<add name="ApplicationServices"
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|testDB.mdf;User Instance=true"
providerName="System.Data.SqlClient" />
As you can see its using the .\SQLExpress. But if i open SQL Server Management and connect to .\SQLEXpress the database is NOT there.
Actually the reason i need to have access to the db is that i need to add membership info into it via aspnet_regsql.exe.
I also tried this via the aspnet_regsql.exe which pops up a gui and i enter the .\SQLExpress in the server name and i choose the db but the db is not there.
I am confused, why is it not attaching it? but VS 2010 can view it in the server explorer tab.
I created a blank aspx file and loaded it via IE and i presummed this would force the attaching of the db.
I must be doing something wrong?
Can anyone provide any info? I know it must be something stupid i am doing
thanks
data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|testDB.mdf;User Instance=true
remove User Instance=true
and fyi italics don't work in code blocks :P
And connectionstrings.com is a great resource.
Here's another good link for SQL Express, although it's for 2005