Database Settings in Aspose.Tasks

Introduction

Aspose.Tasks for .NET is a powerful library that allows developers to work with Microsoft Project files in their .NET applications. In this tutorial, we’ll focus on importing projects from a Primavera database using Aspose.Tasks.

Prerequisites

Before we begin, make sure you have the following:

  • Basic knowledge of C# programming language.
  • Visual Studio installed on your system.
  • Aspose.Tasks for .NET library installed. You can download it from here .
  • Access to a Primavera database, along with the necessary permissions.

Import Namespaces

First, you need to import the necessary namespaces into your C# project. These namespaces provide access to the classes and methods needed to work with Aspose.Tasks for .NET.

using Aspose.Tasks;
using System;
using Aspose.Tasks.Connectivity;

using Aspose.Tasks.Saving;

Now, let’s break down the provided example code into multiple steps:

Step 1: Define Connection String

var connectionString = "Data Source=" + DataDir + "\\PPMDBSQLite.db";

In this step, we define the connection string to connect to the Primavera database. Ensure that you replace DataDir with the directory where your database file is located.

Step 2: Create Database Settings

var settings = new PrimaveraDbSettings(connectionString, 4502);

Here, we create an instance of PrimaveraDbSettings class, passing the connection string and the project ID as parameters. Adjust the project ID as per your requirement.

Step 3: Set Provider Invariant Name

settings.ProviderInvariantName = "System.Data.SQLite";

Specify the provider invariant name. In this example, we’re using SQLite, but you can change it based on your database provider.

Step 4: Load Project

var project = new Project(settings);

Create a new Project object, passing the database settings as a parameter.

Step 5: Save Project

project.Save(OutDir + "SupportForSQLiteDatabase_out.mpp", SaveFileFormat.Mpp);

Finally, save the project to the desired location with the specified file format.

Conclusion

In this tutorial, we learned how to import projects from a Primavera database using Aspose.Tasks for .NET. By following the provided steps, you can seamlessly integrate project import functionality into your .NET applications.

FAQ’s

Q1: Can I import projects from different database providers using Aspose.Tasks for .NET?

A1: Yes, you can import projects from various database providers by adjusting the connection string and provider invariant name accordingly.

Q2: Is there a free trial available for Aspose.Tasks for .NET?

A2: Yes, you can get a free trial of Aspose.Tasks for .NET from here .

Q3: Where can I find documentation for Aspose.Tasks for .NET?

A3: You can find the documentation here .

Q4: How can I get support for Aspose.Tasks for .NET?

A4: You can get support from the Aspose.Tasks community forum here .

Q5: Do I need a temporary license to use Aspose.Tasks for .NET?

A5: If you want to evaluate the full functionality of the library, you can obtain a temporary license from here .