Dim ocb As New OleDbConnectionStringBuilder() ocb.Provider = "SQLNCLI10.1" ocb.DataSource = "serverName" ocb("Initial Catalog") = "targetDB" ocb("User ID") = "sa" ocb("Password") = "allsys" ' Provider=SQLNCLI10.1;Data Source=serverName;Persist Security Info=False;Password=allsys;User ID=sa;Initial Catalog=targetDB connectionString = ocb.ToString() Dim con As New SqlConnection(connectionString) con.Open()
Dim scb As New SqlConnectionStringBuilder() scb.PersistSecurityInfo = False scb.UserID = "sa" scb.Password = "allsys" scb.InitialCatalog = "targetDB" scb.DataSource = "serverName" ' Data Source=serverName;Initial Catalog=targetDB;Persist Security Info=False;User ID=sa;Password=allsys connectionString = scb.ToString() Dim con As New SqlConnection(connectionString) con.Open()