User Instance=True causes invalid connection string

Whenever I use "User Instance=True" as in the connection string below, I get an invalid connection string error. If I take it out, the connection string generates other errors.

"Provider=SQLNCLI.1;Integrated Security=SSPI;Persist Security Info=False;User Instance=True;AttachDBFileName=|DataDirectory|\DbName.mdf;Data Source=.\\sqlexpress;"

Removing User Instance=True always eliminates the invalid connection string message.

BTW, I tried both Data Source=.\\sqlexpress and Data Source=.\sqlexpress.



Answer this question

User Instance=True causes invalid connection string

  • Arto

    i would disagree with this. There are many use this feature of sql server express. yes u r right that userinstance is a embedded database. and it works well.

    Madhu



  • mikeisaac

    Make sure that you are using SQL Server Express, as the User instance functionality is only supported within that edition.

    Jens K. Suessmeyer.

    ---
    http://www.sqlserver2005.de
    ---

  • dsandor

  • ankit_ttgls

    Hey,

    Never used User Instance; I didn't even think it was part of the connection string for SQL Server... Also, I thought Provider was eliminated also...


  • Deepa7476

    Hey,

    I didn't find the Provider statement there though. Try removing that.

    Brian


  • Naoko

    I've tried it both with and without Provider; it made no difference.

    The following connection string worked:

    strDbConn = "Provider=SQLNCLI.1;Integrated Security=SSPI;" & _
    "Persist Security Info=False;" & _
    "AttachDBFileName=" & DbPath & ".mdf;Data Source=.\sqlexpress;"

    User Instance supposedly allows using a local copy of a database via SqlClient (SQLNCLI) vs. the parent SQL Server Express instance. So, it would seem that Provider in some form would be needed. The example on the link I listed in the previous post includes: providerName="System.Data.SqlClient"

    I just hope the above connection string continues working.


  • Mel8240

    Connection string only works some of the time. Even with user instance, it stops working when deployed. I can no longer consider sql server 2005 express a usable product. I've literally lost weeks in trying to make this work.

    I didn't start using sqlexpress because it was free; I was trying to developer software with an embedded database that could be deployed to users. sqlexpress just doesn't work well enough.


  • TCRavn

    To use the User Instance functionality you need to enable it on the SQL Server. This is done by executing the following command: sp_configure 'user instances enabled', '1'. To disable the functionality execute sp_configure 'user instances enabled', '0'.



  • User Instance=True causes invalid connection string