Ejemplo n.º 1
0
 /// <summary>
 /// Open a database connection to the project.
 /// Given the Project, get the name and directory
 /// of the project.  Then open a connection to the
 /// database.
 /// </summary>
 /// <param name="project">Project that the database will be opened.</param>
 /// <returns>Database connection to Project database.</returns>
 public static SQLiteConnection OpenProjectDB(Project project)
 {
     try
     {
         // Create full path to the project database
         //string projectFullPath = project.ProjectFolderPath + @"\" + project.ProjectName + ".db";
         string projectFullPath = project.GetProjectFullPath();
         string projectConnection = "Data Source=" + projectFullPath;
         var conn = new SQLiteConnection(projectConnection);
         conn.Open();
         return conn;
     }
     catch (SQLiteException e)
     {
         log.Error("Error opening Project database: " + project.ProjectName, e);
         return null;
     }
     catch (Exception e)
     {
         log.Error("Error opening Project database: " + project.ProjectName, e);
         return null;
     }
 }