views:

261

answers:

1

I am trying to open a SQL data connection using powershell script and my password contains a $ sign:

$cn = new-object system.data.SqlClient.SqlConnection("Data Source=DBNAME;Initial Catalog=Catagory;User ID=User;Password=pass$word;")

When I try to open a connection it says Login failed.

+9  A: 

Did you try escapting it by using - backtick (`) as an escape character for the dollar sign ($).

Also, did you try enclosing the statement in single-quotes instead of the double-quotes you are using now?

Shankar Ramachandran
Works perfectly with single quotes ! Thanks !
Murtaza RC