To test a connection string (in my case with MultisubnetFailover parameter) I used this simple PowerShell script:
$conn = New-Object System.Data.OleDb.OleDbConnection
$conn.ConnectionString = $ConStr
$conn.Open()
$Tables = $Conn.GetOleDbSchemaTable([System.Data.OleDb.OleDbSchemaGuid]::tables,$null)
$Tables | FT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE,DATE_CREATED | More
$conn.Close()
$ConStr='Server=SQLdevCluster1;Database=TESTDB1;Trusted_Connection=yes;Provider=SQLNCLI11;MultisubnetFailover=TRUE'
$conn = New-Object System.Data.OleDb.OleDbConnection
$conn.ConnectionString = $ConStr
$conn.Open()
$Tables = $Conn.GetOleDbSchemaTable([System.Data.OleDb.OleDbSchemaGuid]::tables,$null)
$Tables | FT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE,DATE_CREATED | More
$conn.Close()
The server must have SQL 2012 native client installed and the account you use to run this script must have permissions to connect to the SQL server (SQLDEVCluster1) and access the database (TESTDB1)
Comments
Post a Comment