Home > Database > SQL Connection String using SqlConnectionStringBuilder Class

SQL Connection String using SqlConnectionStringBuilder Class


Dim strConnection as String
Dim SQLDataName as string
Dim SQLServerName as string

' read connection string from app.config AppSettings

strConnection = Configuration.ConfigurationManager.AppSettings("dbConnection")
 Dim sqlBuilder As New SqlConnectionStringBuilder

' assign Connection string to SqlConnectionStringBuilder Classes ConnectionString Property
sqlBuilder.ConnectionString = tempstr

' now you have access to all of the elements that make up the Connection string

SQLDatabaseName = sqlBuilder.InitialCatalog
SQLServerName = sqlBuilder.DataSource

Advertisements
Categories: Database Tags:
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: