Non-default SQL Server instance ignored in connection string

  • In the following connection string SQLEXPRESS instance is ignored and the default instance is used.

    Does anyone know why?

    Thanks,

    Mark

    SqlConnection sqlcon = new SqlConnection(@"Data Source=10.0.70.2\SQLEXPRESS,13300;Initial Catalog=FOOBAA;User Id=FOO;Password=BAA;");

  • just remove @ from your connectionstring and you should be ok

    If sqlbrowser service is running, you don't need to supply the port number (,13...)

    Then you can remove that part.

    SqlConnection sqlcon = new SqlConnection("Data Source=10.0.70.2\SQLEXPRESS;Initial Catalog=FOOBAA;User Id=FOO;Password=BAA;");

    In the other case (sqlbrowser not running) you should use :

    SqlConnection sqlcon = new SqlConnection("Data Source=10.0.70.2,13300;Initial Catalog=FOOBAA;User Id=FOO;Password=BAA;");

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply