views:

28

answers:

1

Hi to all,

In my installer, I am using System.Data.SqlClient.SqlConnection(connectionstring) to check if I can connect to the SQL server instance. When a user provides the connection string, I remove the "initial Catalog=..." part and try an SQLConnection.Open(). If all is fine, then I proceed in setting up the database (i.e. attaching etc).

This appeared to be working fine, but today all my tests using a remote machine do not work.

First, my initial approach (removing initial catalog) works fine for a local machine, so is this the correct way of doing this for a remote machine?

Secondly, if it is not correct, what is the best way to do this?

JD

+1  A: 

The problem with that aproach is that it relies on the user you are connecting as having a valid default database that they have the permision to connect to, if they do not you will not be able to connect. You could try connecting to the master database explicitly.

Ben Robinson
Hi Ben, Thank you for the response. I am trying to find a work around at a customer site and have create the user on the remote machine and the user has the default database as master. The role is public but I still cannot seem to connect. I even tried sysadmin but still no joy. Any ideas?
JD
Hi Ben, I tried explicitly connecting to master database and this does not work either.
JD
Sounds more like an enviromental/infrastructure issue on the client site. Can you connect to the database from the "remote machine" using any means, e.g. can you set up and ODBC connection, could you connect with SQL server management studio. What do you get if you open a command prompt and type 'telnet servername 1433' but replacing 1433 with the correct port if it is not on the default. Perhaps there is simply no network route between you and the SQL server or the SQL server port is blocked by a firewall.
Ben Robinson
Hi Ben, okay, from my machine and another developers machine (which has sql server on ), I tried to telnet in and no luck. Then I tried an sqlconnection with another database on the remote server (not the master database) and still no luck. Unfortunately network is all tied down and I am unable to get hold of the n/w admin. Thanks for all your help. Maybe on the client n/w the solution may work.
JD
Hi Ben, found it. TCP/IP not enabled on sql server. All working fine.
JD