0

I have a strange problem. I'm trying to connect to a Microsoft SQL server from C# (.Net 4.0). The server is running MSDE2000(8.00.194). When I connect I get the following message:

System.Data.SqlClient.SqlException (0x80131904): 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: TCP Provider, error: 0 - No connection could be made because the target machine actively refused it.)

My connectionstring looks like this,(yes i'm using a blank password): "User Id=sa;Password=;Data Source=192.168.0.100\?,1433;Trusted_Connection=false;Initial Catalog=DATABASE1;"

I've tried changing pretty much everything in the connection string to get it to work without success. I've even tried doing an OleDBConnection instead of the SqlConnection but without success.

The strange thing is that when I connect through Microsoft Management Studio I'm able to connect and see everything. But I get disconnected between every command I send and have to reconnect.

Does anyone know what the problem might be or where I should start looking to find the problem?

Edit: I might add that I tried to telnet to the machine on port 1433 but got "Connection closed by host". The thing is that I do not have access to the computer so I can't check firewall settings but isn't the Management Studio connecting the same way as .Net do?

chiefi
  • 101
  • 3
  • 12
  • I've tried to do the connectionstring withouth \? aswell with the same result. The connectionstring works great against MSSQL 2008 Express. I've checked what syntax it should be against MSDE2000 and what I found it should be correct. – chiefi Sep 12 '11 at 15:16
  • hmm I'm used to seeing an Instance Name following a slash after the IP . I also haven't seen the `\?` documented anywhere – Conrad Frix Sep 12 '11 at 16:08
  • The \? might not be valid against MSDE2000 but it is valid against 2008 atleast. Either way i've tried without it and I still get the same result. I feel its not the connectionstring thats the problem but the server somehow declines me. I can't for the love of god figure out why it works through management studio though. :/ – chiefi Sep 12 '11 at 16:38

1 Answers1

1

Are you sure the instance of such MSDE 2000 is up and running? can you connect to that instance remotely with your SQL Management Studio? Who has installed that instance? by default tcp connections are disabled in a default install, this still happened also in SQL Server 2005 Express (not sure about the 2008 version) so unless the guy who installed it has configured it properly or knew how to set it up, you could be missing some protocols to be enabled.

is that instance available locally on that machine?

check here for default connection strings, I also doubt that ? is a valid instance name and if you know the instance name you should specify it,

http://connectionstrings.com/sql-server#p1

Davide Piras
  • 43,984
  • 10
  • 98
  • 147
  • Yes the instance of MSDE 2000 is up and running. Yes i can connect to that instance remotely with my SQL Management Studio. Some italian guy installed it. I have no clue about his knowledge so maybe this is the problem. I can't access the machine so i have no clue if the instance is available locally. And about \? you are probably right but as i wrote earlier it doesn't work without it either. Lets say the TCP/IP protocol isn't enabled as it should, how can I connect with SQL Management Studio? Maybe it is using some other protocol? – chiefi Sep 12 '11 at 18:11