$SQLconnection = New-Object System.Data.SqlClient.SqlConnection
$SQLconnection.ConnectionString = "Server = MySQLservername\MSSQLSERVER; Database = "MYSQLDB"; Integrated Security = True"
$SQLconnection.open()
In MSSQL 2012, works. In MSSQL 2005, got SQL Network Interfaces, error: 25 - Connection string is not valid.
If use "Server = MySQLServername" only in connectionstring, works. I am sure the instance name is right. Is it a bug of SQL 2005?
Per MS, you can't connect to the default instance, MSSQLSERVER, by name. You have to omit the instance name. I've verified this same "feature" in MS SQL 2008R2 and 2014 SP2.
There might be something that you configured in 2012 that enabled it, but my default setups don't work with it.
If your database/instance is provided on a port number, I got the error 25 when I didn't set up the connection string correctly.
$SQLconnection.ConnectionString = "Server = MySQLservername.domain.ext\InstanceName, PORT; Database = `"MYSQLDB`"; Integrated Security = True"
For example:
$SQLconnection.ConnectionString = "Server = SQL01v.fordco.prd\DBSYS, 1433; Database = CarsDB; Integrated Security = True"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With