0

I would like to connect to an instance of SQL server over the network (or VPN) using Windows integrated security.

What steps exactly are necessary for me to accomplish this? I am using Winforms.

JJ_Jason
  • 349
  • 8
  • 24

1 Answers1

0

You need to provide a connection string from a config file and use this to create an SQL connection; a typical example for integrated security might be:

Persist Security Info=False;
User ID=frosty;Password=flakes;
Initial Catalog=milkjug;
Data Source=supermarket
Integrated Security=True;
provider=System.Data.SqlClient;

Where 'supermarket' is your fully qualified database name (or IP address); this can also include port numbers.

In your code a block like the following:

SqlClient.SqlConnection myConnection = New SqlClient.SqlConnection();
myConnection.ConnectionString = myConnectionString;
myConnection.Open();

The above is not tested and is from memory - should do the trick or at least point you in the right direction.

Peter Smith
  • 5,528
  • 8
  • 51
  • 77
  • I don't believe this answers my question. The whole point is in not storing the user name and password on the client PC. – JJ_Jason Jul 17 '12 at 14:58
  • My bad - I combined two connection strings and forgot the final check.Just delete the User ID and Password items and that should do it. – Peter Smith Jul 18 '12 at 07:37