Remote Connection Error in Asp.net - c#

I am trying to make a registration page, that stores Username, password,and email,
but
When ever i try to Connect database using this string,
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["RConnectionString"].ConnectionString);
conn.Open();
Following Error appears:
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)
I searched everywhere, but it didn't helped me..

The issue starts from web.config and the connection string that is located at RConnectionString according to the code line you give.
Locate this string and fix it to been able to connect to your database.
And some examples here: Setting up connection string in ASP.NET to SQL SERVER

Related

Can't connect local mdf database file

I build a simple CRUD app in C# and used server based database file (.mdf) in my Project. My connection string is like this:
public string connectionString { get; set; } = $"Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=\"{AppDomain.CurrentDomain.BaseDirectory}Passwords.mdf\";Integrated Security=True";
In my computer application works fine just I want, but after send to my friend, he got error that can't connect or find SQL database. Error text is:
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
So we download SQL server express 2019 for him (I use 2017 by the way) and after that, still he get the same error. I dont understand what is the problem. Any succession?

connecting database to server probably [duplicate]

This question already has answers here:
Cannot Connect to Server - A network-related or instance-specific error
(54 answers)
Closed 3 years ago.
I tried making a site for a school project and when I go ahead and input values in the labels in the register page and send it starts loading for some time and then opens up the code in the server side:
SqlConnection conn = ConnectToDb(fileName);
in this line -----> conn.Open();
and this error msg appears:
System.Data.SqlClient.SqlException: '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)'
You should check your connection string and that you have enough permissions to connect to that database
This is likely because (1) you have the wrong connection string (Example: Wrong server name), or (2) you're loading the connection string from a missing/invalid configuration file. For example, if you're running in debug mode and you your application is trying to load *.debug.config file.
There are other reasons, like you are using NT Authentication and the identity your application is running under does not have SQL Server access.

SQL connection not connecting to Claims database

I cant connect to my claims database on a copy of a github project. I keep getting:
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)
I'm able to connect using the same connection string in another project, but not this one. Are there any files besides appsettings.json I need to change?
appsettings.json
"ConnectionStrings": {
"DefaultConnection": "Server=xxx.206;Database=test_MIM; User ID = me; Password= notpassword;Trusted_Connection=False;MultipleActiveResultSets=true"
},

SQL SERVER ERROR (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

I'm working on a website using ASP.NET, C# and mssql.
When I run the website on our local server it is working fine.
The following error occurs when I run it on a shared server:
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)
I don't know how to play with connection string now since I'm very new to this.
It is recommend to keep the connection string in web.config.
To create a valid connection string with SQL Server (either located on network or locally), use following steps:
Steps:
Create a Test.UDL file at your desktop.
Double click the file to see undermentioned Data Link Properties
Select provider i.e SQL Server in your case
Provide connection details i.e. server, username, password etc. in Connection tab.
Test Connection on connection tab and press "OK".
Open UDL file in notepad to see valid connection string.
UPDATE
check following link for creating UDL http://msdn.microsoft.com/en-us/library/e38h511e(v=vs.71).aspx
check following link for connection string Setting up connection string in ASP.NET to SQL SERVER

Connecting to a database

I'm trying to connect to a database but nothing I try works.
SqlConnection conn = new SqlConnection(#"Data Source=C:\Users\Gerard Foley\Desktop\Northwind.sdf");
conn.Open();
No matter what I try I just get the 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)
I stole the connection string from Database Explorer -> Properties -> Connection String. What am I missing? I can get the tables to show up in a DataGridView fine (by dragging from Data Sources), but I want to use my own UI and queries. I just can't seem to figure this ADO thing out.
Using c# express 2010 and sql server express 2008.
for the proper connection string to use to connect to SQL Server have a look at:
http://connectionstrings.com
the connection string you are using now is strange, it should contain server name and database name, see link above for examples...
GOT IT. I should have been using Sql*Ce*Connection. The connection string was fine.
You need to specify 'AttachDbFileName' in the connection string. See the examples for sql server express here: http://www.connectionstrings.com/sql-server-2008.

Categories