As this is my first post on your forum I would like to say a warm Hello World! to everyone I have received a sample code to establish a connection to an external database. Unfortunately, this code is in VB.NET which does not really match my request. I think its possible to find an alternate code that will work with VBA, and that is why I am here seeking your help. I will be very thankful for any advice. Imports System.Data.SqlClient
Using Connection As New SqlConnection("Data Source={server}\{instance};Initial Catalog=master;User ID={Username};Password={Password}")
Connection.Open()
Dim ret As SqlCommand = Connection.CreateCommand
ret.CommandText = String.Format("use {0}; {1}", Environment, "[Your SQL here]")
End Using
|