I press add connection in database explorer then put the server name which is Rabbitmasterpc
windows Authentication, attach a database file: --> I browse to the database i attached.. give it a logical name..click 'ok'. And what I get:
"A network-related or instance specific error occured while
establishing a connection to SQL Server. The server was not found or
was not accessable. Verify that the instance name is correct and that
SQL Server is configured to allow removte connections. (provider:
Named Pipes Provider, error:40- Could not open a connection to SQL
server)"
UPDATE:
http://www.mssqltips.com/tip.asp?tip=1673
The article says it is in facets..but i dont have it inside
Check if SQL Server is configured (via SQL Server Configuration Manager) to accept remote connections.
Also, you may need to check the Connections property page for your database in Management Studio, as well as firewall settings:
http://blogs.msdn.com/b/walzenbach/archive/2010/04/14/how-to-enable-remote-connections-in-sql-server-2008.aspx
Try using code below to open the connection.
Try
Dim objconnection As SqlConnection = New _
SqlConnection("Server=localhost;Database=DATABASENAME;" & _
"user ID = YOURUSERID; password = YOURPASSWORD;")
objconnection.Open()
objconnection.Close()
MessageBox.Show("Database Connection Success")
Catch ex As Exception
MessageBox.Show("Database Connection Error: " & ex.Message)
End Try
Related
Getting following exception two week once in PROD, when calling azure function from core api 3.1.
Below issue occurred when establishing the connection with oracle DB using ADO.Net. especially when executes the conn.open().
OracleConnection conn = new OracleConnection(connStr);
conn.Open();
OracleCommand cmd = new OracleCommand(strSQLQuery, conn)
{
CommandType = CommandType.Text
};
OracleDataReader odr = cmd.ExecuteReader();
Once restarted the app service from azure portal, it would be resolved.
Error - ora-12545 network transport unable to resolve connect hostname.
Please check if below can be worked around.
If you are using the tnsname.ora,Please make sure its configured
correctly. Check tnsname.ora file for prod and check for
servername,See if the prod listener exists in listener.ora file, it
must be missing.So try to add the listener for prod environment similar to dev
,if present.
If the Connection string had DNS name, try replacing it with IP
address. Try to use user service name as they have different names for
product and dev separately which can be useful even if SID is same
(in some cases).Always Ensure that the host field of the local_listener is
properly set to a name which can be resolved by the Oracle client.
Or
Try to update host files to contain the requird server and host port.
Go to
\etc\hosts . Insert server name and
server IP in here and save.
Also check the .net version , it may be incompatible sometimes,
maybe that’s why , after restarting ,its setting itself and the
problem is resolved in azure app service.or Some times issue maybe
due to firewall being restricting in azure portal.
You can raise a support request from overview page from troubleshoot blade ,if the issue still remains.
Reference:
oracle - Stack Overflow
In the Data Environment, you can setup the connection via accessing the Properties of the connection.
From there, you can choose the provider, the server name, and the database (I am using SQL Server 2008, by the way).
However, I see a problem in this since the connection string cannot be altered anymore once deployed. Therefore, I set the connection string of the Data Environment Connection during log on.
With deMain.conn1
.ConnectionString = connString
End With
where connString is a global variable containing the connection string that is read from a .ini file.
I ran the program and encountered the following error:
I figured it out. In the Properties window of the Data Environment Connection, you must select first the correct Provider and click Next.
In the Connection tab, you don't have to fill-out the fields anymore.
I am working with Microsoft Visual studio Test, I do not know how to deal with 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: SQL Network Interfaces, error: 26 – Error Locating Server/Instance Specified)
Make sure your database engine is configured to accept remote connections
Start > All Programs > SQL Server 2005 > Configuration Tools > SQL Server Surface Area Configuration
Click on Surface Area Configuration for Services and Connections
Select the instance that is having a problem > Database Engine > Remote Connections
Enable local and remote connections
Restart instance
Check the SQL Server service account
If you are not using a domain account as a service account (for example if you are using NETWORK SERVICE), you may want to switch this first before proceeding
If you are using a named SQL Server instance, make sure you are using that instance name in your connection strings in your ASweb P.NET application
Usually the format needed to specify the database server is machinename\instancename
Check your connection string as well
4.You may need to create an exception on the firewall for the SQL Server instance and port you are using
- Start > Run > Firewall.cpl
- Click on exceptions tab
- Add the sqlservr.exe (typically located in C:\Program Files (x86)\Microsoft SQL Server\MSSQL.x\MSSQL\Binn), and port (default is 1433)
- Check your connection string as well
If you are using a named SQL Server instance, make sure you are using that instance name in your connection strings
Check SQLBrowser; check that it is running. You may also need to create an exception in your firewall for SQLBrowser.
Check that you have connectivity to the SQL Server. Note what you are using to connect: machine name, domain name or IP address? Use this when checking connectivity. For example if you are using myserver
Start > Run > cmd
netstat -ano| findstr 1433
telnet myserver 1433
ping -a myserver
Check what ports are IP addresses are being returned.
Alternative:
If you still can’t get any connection, you may want to create a SQL account on the server, a corresponding SQL user on the database in question, and just use this username/password combo in your web application.
Credits for this answer goes to belle of sqlmusings.com
been trying to configure an ADO.NET connection for my Visual Studio application but I am running into issues and having no luck at all troubleshooting them. The major error that I run into is:
A network-related or instance-specific error occurred while establishing a connection to SQL server. The server was not found or not accessible. Verify the instance name is correct and that SQL server is configured to allow remote connections (Error 40: Could not open connection to the SQL server)
The steps I undertook to troubleshoot this are:
1. Open up Sql server configuration manager and under the SQL Server Network Configuration, Protocols for MSSQLSERVER,SQLExpress, SQL server 2008 connection string data source I enable each of the protocol names (Shared memory, Named pipes,TCP/IP,VIA)
As instructed I stop the SQL server services first under the SQL server services nodes.
Now I click start, MSSQL server service starts but both SQL Server 2008 and SQLEXPRESS agents do not. Stating the following:
The request failed or the service did not respond in a timely fashion. Consult the event log or other applicable error logs for details
This might just be the problem as when I attempt to create the connection string , the server name specified is MYWORLD/SQL SERVER 2008. Since the SQL server 2008 agent service refuses to start, the connection fails, leading to the first error message.
Does anybody have any leads on this and can let me know the necessary steps to mitigate this.
The SQL Browser service must be running to connect to a named instance.
Use SQL Servr Configuration Manager under Configuration Tools under Microsot SQL Server 2008 to assign the logon accounts for each service you want to run. Do NOT use any other method to assign user accounts because the correct rights will not be enabled.
I have a web site developed locally with a local Sql Server database. I also have a web host that provides one Sql Server database for my site. Now I want to deploy the application, and I would like to be able to manage the remote database from the Server Explorer in Visual Studio. I have the connection string used in the application, which works fine for adding, say, a datasource to a control etc. But I don't know if there's any way to use it to connect the database inside the Server Explorer so that I can add tables etc. I have read that you're supposed to be able to this instead of using the Sql Server Management Studio, but I have'nt read anything about how to connect to the remote database in it.
What I have tried so far is this: I have selected Add database in Server Explorer. This brings up first a dialog where I choose Sql Server. And then I get a dialog where I can set Server name (which I tried using the ip address in the connection string below), and Authentication (where I chose Sql Server Authentication, with the user id and password from below). But when I test the connection it fails.
Here's the connection string, which works fine when used for datasources in the application (obviously with different user name and password):
Any help appreciated!
EDIT:
Well, I've done everything suggested by lewiguez below now, but it doesn't make any difference. I can't believe this should be so hard... I keep getting this error message in Sql Server Management Studio:
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) (Microsoft SQL Server, Error: 53)
Here's the process I follow for working with remote databases:
In VS 2008 under the Server
Explorer tab, right-click on "Data
Connections" and then click "Add
Connection"
Change the Data Source to
"Microsoft Sql Server"
Put in your fully-qualified
"Server Name" (be it IP Address, domain name, etc.), select "Sql Server
Authentication" and put in "User
Name" and "Password" for the database user
Select the database you want to connect to under "Select or enter a database name"
Hit "Test Connection" to test and then "OK" to accept
You should be able to interact with the database at this point by expanding the connection and then the "Tables" folder. For example, right-click on the Tables folder and you'll be presented with an "Add Table" option in the dialog. Right-clicking an existing table will bring up the "Open Table Definition" options where you can change any columns, etc.
If you're not getting to this point (and it sounds like you're not), I'd recommend checking your Sql Server connection from whatever machine you're using.
I generally do this by going into the Management Studio and connect with whatever credentials I'm trying to use. If they don't work, make sure they are, in fact, added as a Sql Server user and a database user (they have to be both).
Also, I would check in the Sql Server Surface Area Configuration Manager. You have to allow TCP connections and you have to be set up to allow Sql Server Authentication connections as well from remote hosts. If THAT'S all set up, but you still can't connect, I'd double-check to make sure your firewall is allowing Sql Server connections. The default port is 1433.
Also, if you can connect, but then can't write to anything, double-check your table permissions. Hope this helps!
I finally understood the problem: as I suspected the settings in my own installation was not the problem, but rather it was the settings on the Sql Server installation on my web host. And in fact I found a place in the control panel on my web host where I could set an exception to my ip address so that my ip would be granted access to the port 1433 for Sql Server, which is otherwise closed by default for security reasons.
I've had no luck finding any information about this at all on the internet, which I find strange. All the information I could find had to do with changing these settings on your own local installation of Sql Server. But I'm sure there are loads of people out there who like me use a web host for deploying their web site, and then that info doesn't seem to apply. (Perhaps apart from the TCP setting, which I think must be set, and there's detailed info about that here: http://www.linglom.com/2009/03/28/enable-remote-connection-on-sql-server-2008-express/ )
Hope this helps someone else who like me uses a web host. Now everything works fine for me at least, both in Management Studio and in Visual Studio Server Explorer.