views:

56

answers:

4

i am connecting to sql server 2000 on a remote computer with a dotnet application, but when i try to open the connection it gives the following error:

When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections

What is this?

A: 

It means that the remote SQL server is configured to not allow remote connections.

From this forum discussion:

  1. Make sure SQL SERVER is up and the instance you try to connect is running.
  2. Your system Firewall should not block SQL Server port.
  3. Go to Computer Management >> Service and Application >> SQL Server 2005 Configuration >> Network Configuration Enable TCP/IP protocol. Make sure that SQL SERVER port is by Default 1433.
  4. Now follow this KB Article of MSDN depending on your server.
Oded
A: 

Are you sure you're connecting to a sql server 2000 instance?
Possibly it's been upgraded to 2005?

Try following the procedure here: http://support.microsoft.com/kb/914277 to allow remote connections.

Bravax
A: 

By default, as a security feature, SQL Server 2005 does not enable connections from other machines on the network.

Verify that your SQL Server and its databases are suitably secured (for example, have proper user accounts and passwords, etc.). Once you are satisfied, go to Start, Program Files, Microsoft SQL Server 2005, Configuration Tools, SQL Server Surface Area Configuration. Look for Database Engine, Remote Connections and change the setting to allow remote connections.

binarycoder
But he said that he is running SQL Server 2000, not 2005!
Jaywalker
<But he said that he is running SQL Server 2000> See the error message also posted. The error message clearly is from SQL Server 2005.
binarycoder
A: 

To connect to SQL Server from C#.NET, you need to create a connection string such as below:

private SqlConnection connection; private string connectionString = @"Server=(local);Database=Embedding_SQL_Test;User ID=sa;Password=123"; connection = new SqlConnection( connectionString );

Next, you use the SqlConnection object created above to create a 'SqlCommand', as shown below: SqlCommand cmd = new SqlCommand( "select * from Customer where CustomerID = @Cid", connection);

The SQL query shown here can be replaced by a SELECT, INSERT, UPDATE queries etc.

Next to execute the SQL queries in the database, you use the following methods: ExecuteReader - to execute SELECT queries ExecuteNonQuery - to execute INSERT, DELETE, UPDATE, and SET statements.

This is a very short description of how to connect to SQL Server database from C# and execute SQL queries in the database. For details about the connection string, the methods and their parameters check the following link: ( http://www.shahriarnk.com/Shahriar-N-K-Research-Embedding-SQL-in-C-Sharp-Java.html ) Here you will also find details about how to pass parameters to the SQL queries as well as calling stored procedures and much more.

SNK111