Search code examples
c#sql-servervisual-studio-2010openfiledialog

use openfiledialog to get path of open database C#


I'm using Visual Studio Expess 2010. I am trying to figure out how to use the openfiledialog to getthe path of my database.

Currently I close the connection to my database and then try to select the database in the open file dialog but Windows tells me: "This file is in use, close the file..."

If I've closed my db connection what else do I need to do to completely close the file so I can select it in the openfiledialog?


Solution

  • Closing the connection doesn't leave the Stream created to the file. Dispose the object you are using to set up the connection.