none
connection stri RRS feed

  • Question

  • I am having an issue with my connection string in the app.config file. If i leave the way the it was automatically created I cannot update my database but the tableadapter.fill method works.


    connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\sample.mdf;Integrated

    Security=True;Connect Timeout=30;User Instance=True"

     

    If I change the |DataDirectory| part to the path to the database within my project everything works.

     

    Any ideas why this isn't working for me?

     

    Thanks

    Friday, November 2, 2007 9:14 PM

Answers

  • No just a little bit more work because you can just backup the database and add code that will restore it during installation.  So when you create the setup you add the .bak and the restore code which also means you have to run test deployments in you box to fix issues as needed.

     

     

     

    Saturday, November 3, 2007 4:13 PM

All replies

  • It could be related to user instance it comes with many restriction and limitation.  You could convert the user instance to server instance because user instance it limited to one per user.  Try the link below for how to convert the user instance to server instance.

     

    http://blogs.msdn.com/sqlexpress/archive/2006/11/22/connecting-to-sql-express-user-instances-in-management-studio.aspx

    Friday, November 2, 2007 11:38 PM
  • But it works if I replace |DataDirectory| with an absolute path to the database copied to my project directory. I keep everything in the connection string the same other then that.

     

    Thanks

     

    Saturday, November 3, 2007 3:41 AM
  • That could mean you are in Winform application which does not use the DataDirectory. But the reason you may want to convert to server instance are many, a server instance can run as long as you are using it while user instance can only run 60 minutes at a time.

     

    Saturday, November 3, 2007 2:39 PM
  • Thanks for the help it is a Winform application and I will look into a server instance. So will not being able to use the DataDirectory effect creating a build to install on other computers?

    Saturday, November 3, 2007 3:22 PM
  • No just a little bit more work because you can just backup the database and add code that will restore it during installation.  So when you create the setup you add the .bak and the restore code which also means you have to run test deployments in you box to fix issues as needed.

     

     

     

    Saturday, November 3, 2007 4:13 PM
  • OK thanks for the help

     

    Saturday, November 3, 2007 10:18 PM