ADODBD connection from ConnectionString

Dim connectionStringName As String = "TestConn"

Dim s As New StringBuilder

Dim a As ConnectionStringSettings = ConfigurationManager.ConnectionStrings(connectionStringName)

 

 

s.Append("ConnectionString: " & a.ConnectionString & "<br />")

s.Append("Name: " & (a.Name & "<br />"))

s.Append("ProviderName: " & a.ProviderName & "<br />")

 

 

Dim sqlConn As String = ConfigurationManager.ConnectionStrings(connectionStringName).ConnectionString

Dim connBuilder As SqlConnectionStringBuilder = New SqlConnectionStringBuilder(sqlConn)

s.Append("DataSource: " & connBuilder.DataSource & "<br />")

s.Append("InitialCatalog: " & connBuilder.InitialCatalog & "<br />")

s.Append("UserID: " & connBuilder.UserID & "<br />")

s.Append("Password: " & connBuilder.Password & "<br />")

s.Append("<hr />")

 

 

' Build an ADODBD connection string

Dim d As New StringBuilder

d.Append("Provider=SQLOLEDB;")

d.Append(String.Format("Data Source={0};", connBuilder.DataSource))

d.Append(String.Format("Initial Catalog={0};", connBuilder.InitialCatalog))

d.Append(String.Format("User Id={0};", connBuilder.UserID))

d.Append(String.Format("Password={0};", connBuilder.Password))

d.Append("<hr />")

 

 

Literal2.Text = s.ToString & d.ToString

Post a comment

Comments closed