Cannot Access To ASP.NET Configuration Tool - c#

When I want to access to ASP.NET Configuration Tool it gives me the following error message:
There is a problem with your selected data store. This can be caused by an invalid server name or credentials, or by insufficient permission. It can also be caused by the role manager feature not being enabled. Click the button below to be redirected to a page where you can choose a new data store.
The following message may help in diagnosing the problem: Unable to connect to SQL Server database.
What can I do. Is there any configuration which I should set before I can access or ?
I am using ASP.Net MVC4 Project with build in connection string.
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-AccountPortal-20131128183241;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-AccountPortal-20131128183241.mdf" providerName="System.Data.SqlClient" />

you should access your connection string from web.config file before proceeding further.
web.config file :
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-AccountPortal-20131128183241;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-AccountPortal-20131128183241.mdf" providerName="System.Data.SqlClient" />
</connectionStrings>
from code : access connection string which is in web.config file
string connectionstring = System.Configuration.ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;

Related

Get SQL Connection error while using Web Service with local SQL Server database

I'm setting up a web service, I wanted to use the local database so I created a local SQL Server database in this project. The web service runs just fine on localhost, but the problem when I invoke a method to Load data from the local database on this project, I'm getting an error:
System.Data.SqlClient.SqlException:
An attempt to attach an auto-named database for file C:\Program Files (x86)\IIS Express\TourTravelDB.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
TourTravelDB.mdf is my local database
I've added a connection string in my web.config but it's still not working.
Here is my connection string.
<connectionStrings>
<add name="CS"
connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\TourTravelDB.mdf;Integrated Security=True"
providerName="System.Data.SqlClient"/>
</connectionStrings>
I've also tried to move my database to the IIS Express directory, it works but when run it from another computer, I have to move the database again.
Does anyone have an idea how to solve this?
This may help you..
Add "User Instance=True;" in your connection string.
<connectionStrings>
<add name="aspnet_staterKits_Test_TimeTracker"
connectionString="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|aspnetdb.mdf;"/>
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer"
connectionString="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|aspnetdb.mdf;"/>
</connectionStrings>
if doesn't work then try out the below links..
forums.asp.net
codeproject.com
Already existing thread in stack overflow

Invalid value for key attachdbfilename C# Identity Server Connection String

I am trying to create the identity tables in my server database. However, I keep getting an "Invalid value for key 'attachdbfilename'" error.
<connectionStrings>
<add name="DefaultConnection"
connectionString="Data Source=den1.mssql.gear.host;Initial Catalog=groceryapp;User Id=appID;Password=password;AttachDbFilename=|DataDirectory|\UsersDB.mdf;"
providerName="System.Data.SqlClient" />
<add name="appID"
connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string="data source=den1.mssql.gear.host;initial catalog=groceryapp;user id=appID;password=password;MultipleActiveResultSets=True;App=EntityFramework""
providerName="System.Data.EntityClient" />
</connectionStrings>
I am following the tutorial of this video.. https://www.youtube.com/watch?v=Y02ccL4-_K4
EDIT
I changed the |DataDirectory| to my physical path, but now I get permission issues with SQL Server:
ExceptionMessage=CREATE DATABASE permission denied in database 'master'.
Cannot attach the file 'PHYSICAL_PATH\App_Data\UsersDB.mdf' as database 'testDatabase'.
First:
You can try to change that with the physical path of your Users.mdf
Second:
Try to check if user appID has a right create table. If not, give it privilege to create one.

Login failed while connecting to database

I have created WPF application which has MDF file. When I added MDF file to my solutions folder It automatically created a connection string for me
<add name="Connection"
connectionString="Data Source=(LocalDB)\v11.0;Initial Catalog=C:\Users\Public\Desktop\MyDatabase.mdf;Integrated Security=True;"
providerName="System.Data.SqlClient" />
I Deployed my application using SQL Server Compact (as described here). But When I run my Application I am getting exception
Cannot open database "C:\Users\Public\Desktop\MyDatabase.mdf" requested by the login. The login failed.
Login failed for user 'MY-PC\NAME'.
I am using Windows Authentication for my SQL Server
change your connection string as follows:
<add name="Connection"
connectionString="Data Source=(LocalDB)\v11.0;Initial Catalog=C:\Users\Public\Desktop\MyDatabase.mdf;persist security info=True;Integrated Security=SSPI;"providerName="System.Data.SqlClient" />

SQL Exception - Login failed for user "UserName$"

I am having an issue with one of my pages that is pulling content from a database which is displayed in <select> tags. I have seen many others with this issue but haven't seen anyone's have a $ after the user. I am not sure why it is adding a $. I have redone my connection string, .dbml file and have even created a user AD\INFO4420$ in my database and have given it read and write privileges. When using Visual Studios I am able to run the page and there is no error but it only occurs when viewing it from the server.
The Error is as follows:
Login failed for user 'AD\INFO4420W$'.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Login failed
for user 'AD\INFO4420W$'.
Connection String in my Web.config:
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-Final_Project-20131204200025;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-Final_Project-20131204200025.mdf"
providerName="System.Data.SqlClient" />
<add name="TowingApp_dbConnectionString" connectionString="Data Source=INFO4420W.ad.uvu.edu;Initial Catalog=TowingApp_db; Integrated Security=true"
providerName="System.Data.SqlClient" />
</connectionStrings>
I know the program is using the following as the connection string. Any time I comment out the following it throws another error.
<add name="TowingApp_dbConnectionString" connectionString="Data Source=INFO4420W.ad.uvu.edu;Initial Catalog=TowingApp_db; Integrated Security=true"
providerName="System.Data.SqlClient" />
Any help or direction would be appreciated!
You're using integrated security Integrated Security=true. It works locally because your local windows account has access to local SQL Server DB. Perhaps you have to switch to SQL Server authentication with dedicated ID and password.
In that case instead of Integrated Security=true you would specify
User ID=YourUserid;Password=YourPassword;
My guess the ID/Password should be provided to you by the univercity. Also to avoid having ID and password in open text either supply them from code or encrypt the connection string.

appharbor [Win32Exception (0x80004005): The system cannot find the file specified] with model first EF

I have a small project where I used continuous integration with bitbucket and appharbor When I published the project the login is working normally and so on but other database connections gives the following error:
The system cannot find the file specified
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ComponentModel.Win32Exception: The system cannot find the file specified
here are my local connection strings
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-ZeinyCenter-20130614160141;Integrated Security=SSPI;" providerName="System.Data.SqlClient" />
<add name="Model1Container" connectionString="metadata=res://*/Models.Model1.csdl|res://*/Models.Model1.ssdl|res://*/Models.Model1.msl;provider=System.Data.SqlClient;provider connection string="Data Source=(LocalDb)\v11.0;initial catalog=aspnet-ZeinyCenter-20130614160141;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
and here is the appharbor connection string
Server=576666e4-329e-4511-95b9-a1dd00ff4766.sqlserver.sequelizer.com;Database=db576666e4329e451195b9a1dd00ff4766;User ID=yusmzpttdopksbua;Password=H3Ex6jp3wihobPu3W2KZHBpW7tDk8SWtxYWTxabXGXhVBGTAnRJZz6AgLRzKNe4L;
Can someone please help me
I solved my problem typing the connectionString that appharbor gave me on the Web.config.
Steps:
1) Go to appharbor and select your application.
2) Click on add-on, and select SQL Server (install the free one).
3) Then click on Go to SQL Server.
4) Scroll to the bottom and you will see Connection string.
5) Copy all (Click it and press ctrl+A), the part that says Server=bla bla bla.
6) Now go to Visual Studio --> Web.config and paste it in:
add name="DefaultConnection"
connectionString="Your appharbor connectionString"
providerName="System.Data.SqlClient" />
Example, mine was like this:
add name="DefaultConnection"
connectionString="Data Source=(LocalDb)\v11.0;
Initial Catalog=aspnet-DeliveriandoWebApp-20131019135542;
Integrated Security=SSPI;
AttachDBFilename=|DataDirectory|\aspnet-DeliveriandoWebApp-20131019135542.mdf"
providerName="System.Data.SqlClient" />
Now is like this:
add name="DefaultConnection"
connectionString="Server=8a6b279b-0441-49c7-a97e-a2860049ea89.sqlserver.sequelizer.com;
Database=db8edfdf6c279c044149e7a17ea2860049ea89;
User ID=lolyctkwkaebnkj3;
Password=nYhP4hZKDNMLftEaSyeeeS8eVpbs3H3seUZQUQ8PZzMRXA5hPVfDirfPwZzHfvaFDsz;"
providerName="System.Data.SqlClient" />

Categories

Resources