views:

58

answers:

1

I am trying to connect to a database on another network through a vpn. How do I set up the connection string? There is a network password to get on the network and then a database password to connect. Is there a way to set this up?

<connectionStrings>
<add name="remoteDB" connectionString="eng=INV;Links=tcpip(Host=xxx.xxx.xx.xx,xxxx);uid=userid;pwd=password"/>
</connectionStrings>
+1  A: 

There's no, standard, way to define VPN connection settings as part of your connection string. There may be a way with the specific database provider you're using (as what you have in your sample doesn't look much like SqlServer), but you'd need to either clarify what that is incase someone knows, or refer to the documentation for it.

The connection to a VPN is normally establised either by the Operating System or by a 3rd party piece of software such as the Cisco VPN Client and thus is entirely transparent to the software that's connecting to the database. If you want to be able to establish the VPN connection prior to the database connection, programatically, that's a different matter entirely.

Rob
The VPN is setup in the firewall hardware. When I use Window Explorer I can browse to the computer but it will ask me for a Network login and password for the other network. I wasn't sure if the connection string could pass a network login and password and the DB login and password. Or even if this is the right approach.
If you want to have your program connect programatically to VPN you could use the RAS Api: http://msdn.microsoft.com/en-us/library/ms896639.aspx
Josh