Non-ASCII characters in ConnectionString RRS feed

  • Question

  • If I use SQL management studio to login to the SQl2005 server, it accepts the non-ASCII characters in password.
    in C# if my connectionString  contains non-ASCII characters in password, this line of code will bomb out:

    SqlConnection l_objTempConn = new SqlConnection(ConnectionString);

    is there anyway in C# coding to work around this problem?
    Tuesday, January 8, 2008 8:26 PM

All replies

  • Yes, you need to use the escape character sequence.  I think it is the slash in C#.  I personally avoid that method.  I have learned too many languages over the years, each with its own ways of escaping control characters.  I build the strings.


    Code Block
    string quote = Convert.ToString("");




    I now have a single quote.


    Code Block
    Messagebox.Show(quote + "Name in quotes" + quote);



    The above code displays the message in quotes.  I use that technique with all of the goofy characters.  I also find it to be so much easier to read to boot.





    Tuesday, January 8, 2008 9:29 PM
  • If you haven't solved the problem please post your connection string and reproduce it.


    Thursday, January 10, 2008 8:59 AM