Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact


VBA alternation to VB.Net sql connection


VBA alternation to VB.Net sql connection

Author
Message
mehowski
mehowski
Forum God
Forum God (339 reputation)Forum God (339 reputation)Forum God (339 reputation)Forum God (339 reputation)Forum God (339 reputation)Forum God (339 reputation)Forum God (339 reputation)Forum God (339 reputation)Forum God (339 reputation)

Group: Forum Members
Posts: 1, Visits: 8
As this is my first post on your forum I would like to say a warm Hello World! to everyone Smile

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


GO


Similar Topics


Reading This Topic


Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....

















A1VBCode Forums


Search