How do i upload the form autherication data in App_Data folder to my webhost? I have uploaded my project and everything works fine, beside the login. I get this error:
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)
When i try to use the login on the site. Is this error casted because i created the form autherication on my localhost, then the .MDF file is also created with the localhost connectionstring? If so how do i fix this? Generally how do i fix this?
Please check the connection string used in web.config. If you put the automatically created database in app_data folder (aspnetdb.mdf), there should be SQL Express or SQL Server installed on the machine and it should support attaching database in user instance mode.
Related
I have a web application ASP.NET in VB.NET in Azure, which connects to a database. The database is also in Azure, in the same resource group.
But when my app tries to connect with the database, this error appears:
Server Error in '/' Application.
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)
How do I configure my app in order to establish the connection with the database? Which is the correct connection string? Where do I have to paste it?
As you see, I'm a complete noob. Azure shows perfectly all the .aspx pages, and the database runs the querys fine. But it seems to be that I cannot establish the connection between the app and the database.
In the black square you can see where I get the connection string from. In the red square you can see the connection string I copied and pasted in the web.config file and in the vb code of my app. But it still doesn't work:
connection string
I also added a new connection string in my app, setting the connection string I got as the value:
connection string 1
Thanks in advance for your help.
For anyone having my same problem, I've found the solution.
The problem was that my vb code had the connection string. So, it was useless to change the connection string only in the web.config file.
So, in my vb code I wrote a reference to my connection string, via the name of it.
Then, when the app was in Azure, I changed the connection string in the web.config.
And it worked ;)
I've installed SQL Server 2012 and visual studio express for web 2012, I found that I couldn't connect to SQL via asp.net. I installed another SQL Server 2012 instance and changed datasource to (LocalDB)/v11.0, it then works.
But in the security configuration, though I've set the windows authentification,I get this error:
There was a problem with the selected datastore, which could be due to an invalid server name or credentials, or insufficient permissions. It may also be caused by the role manager feature not being enabled. Click the button below to redirect to a page where you can select a new data store.
The following messages may help diagnose the problem: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or cannot be reached. Verify that the instance name is correct and SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26-An error occurred while locating the specified server / instance)”
After testing the provider for storing site management data:Aspnetsqlprovide ’connection with sql,another error happens:
Failed to establish database connection.
If you haven't created a SQL Server database, exit the site administration tool, use the aspnet_regsql command-line utility to create and configure the database, then return to this tool to set up the provider.
Following the error message, I installed aspnetdb to this (LocalDB)/v11.0, and changed the codes in machine.config:
<connectionStrings>
<add name="LocalSqlServer"
connectionString="Data Source=(LocalDB)\v11.0;Initial Catalog=aspnetdb;Integrated Security=True"
providerName="System.Data.SqlClient"/>
</connectionStrings>
I also set IIS connection strings as codes above and changed Application pool identity to“LocalSystem”,but these errors still occurs.
I really hope someone can help me to handle this, thanks
I get this error when I upload the website on the server, ie parallels plesk server. I create the tables on the plesk server and selects SQL server 2012. But I think this is a connection string error. If you know about this error please guide me.
Server Error in '/' Application.
Login failed for user 'db123'.
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 'db123'.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
The Error say you are trying to connect to SQL Server with user db123 which is not exists or exists but you provide wrong password.
To fix the problem
check if the db123 login exists on your SQL Server from plesk panel and is exists in your database users
Open your web.config file to find the connection string section and see the passwrod, then check if the password of db123 login is the same or not
Try connect to you SQL server (on host) from your local SQL Server Management Studio with the user and password which is provided in your web.config to see that everything is fine or not
The problem definitely is from the login credentials. But check to see if you are using Windows authentication.
If you used a default instance during the installation of SQL Server Express, then in the connection string at web.config, clear the username and password portion and set integrated security to true. That worked for me.
With my problem, the SQL server login panel had a user name, but since I was using the default instance, ASP.net did not recognize the username as a valid one even though in principle it was supposed to work. So check integrated security and set it to true. It might work for you
I've created this MVC4 web application and went with a local MDF (localdb?). It's located in the \App_Data folder of my project. It's name is SiteDatabase.mdf.
But right now im struggling with the connection string, how can I "link" it up?
I got this:
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=SiteDatabase;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\SiteDatabase.mdf" providerName="System.Data.SqlClient" />
Where SiteDatabase.mdf is located in my App_Data folder.
The error Im getting:
Server Error in '/' Application.
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: 50 - Local Database Runtime error occurred. Cannot create an automatic instance. See the Windows Application event log for error details.)
Create a udl file, if it connects then the problem is the code / application, if it does not connect, then it's your firewall, connections string, dll library etc. Well the important thing here is probably the connection string. Do the following: create an empty text file and rename it "myconnection.udl". Now double click on the file and it will launch an applet. You can configuer the connection to your database and test it. (it will pick up registered connection libraries etc). If it give OK, then open the udl file in notepad, you will see the correct connection string. Paste to your app connection settings. UDL files are generally misunderstood. They are simply a text file that holds the connection settings. They then call the connection dll. If the udl file works then you have a correct connection string 100%
Try add before your connection string
<remove name="LocalSqlServer" />
I have two ASP.NET websites on a web-server, and two SQL Server databases.
I have a folder for Website #1, which contains a web.config with a connection string pointing to Database #1.
Under the folder for Website #1 there's a staging folder called 'staging', containing Website #2, and the web.config there has a connection string that points to Database #2.
Website #1 works perfectly.
But when I try to run Website 2, I always get the following error:
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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
I've verified that the connection string is correct and that it's pointing to Database #2.
But even when I swap in the connection string from Website #1, which works perfectly on Website #1, it still fails.
Here's what the connection string looks like:
<connectionStrings>
<add name="WebsiteConnectionString" connectionString="Data Source=localhost;Initial Catalog=WebsiteStaging;User Instance = false;User Id=xxxx;Password=yyyy" providerName="System.Data.SqlClient" />
</connectionStrings>
Is there anything unusual going on here that I'm not aware of?
Not sure which version of IIS you're using, but you might need to create two separate web applications: one pointing to the Website #1 folder and the other Website #2.
When you view Properties of the Website/virtual directory, the Application name should be set for both directories. Is this the case?
LOCALHOST is for IIS
(LOCAL) is for SQL Server
My connection strings usually say "Server=(LOCAL);Integrated Security=SSPI...."
I would check the security tab to find out the identity that both web sites are running under.
Really sorry... looks like it wasn't to do with the connection at all.
It was because the Linq-to-SQL data-layer (which was in another project) was referencing its own connection string (even though, wherever I instantiated a DataContext in the Website project, I always used the web.config connection string as a parameter).
But thanks for your answers, those would probably be good things to check, had the above not been the problem.