Please tell me why I failed with this connection...how should I do then?
- local machine name =
MYPC
- local instance name =
MSSQLSERVER
- my own database named
mydatabase
- I use Windows authentication to log into the local server, username =
DOMAIN\mypc
- I have no password when I log into the local server;
Lines I used are here:
$connection= new-object system.data.sqlclient.sqlconnection
$connection
$Connection.ConnectionString ="server=MSSQLSERVER;database=mydatabase;trusted_connection=false;uid=DOMAIN\mypc;"
$Connection.ConnectionString
$connection.open()
These lines failed with the following error:
Exception calling "Open" with "0" argument(s): "A network-related or
instance-specific error occurred while establishing a connection to SQL Server.
The server was not found or was not accessible. Verify that the instance name is
correct and that SQL Server is configured to allow remote connections.
(provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)"
At line:1 char:17
+ $connection.open <<<< ()
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException