March 25, 2004

Accessing an MS Project 2003 file

Can an MVP or someone please help me with this problem I am having? I don't quite understand it and I have spent a lot of time searching Google, USENET and the MSDN for the answer.

The problem is that I can read from most tables described in C:\Program Files\Microsoft Office\OFFICE11\1033\PJOLEDB.HTM but I can not access the Project table at all and I can not access some of the columns in the Tasks table. I have been able to access the Assignments, Calendar, Predecessors, and WBS tables. I havn't tried the others. I am wondering why I am unable to access some of the data.

C# Function that I am using to test the MPP access (I have also tried using an OleDbDataAdapter):

OleDbConnection projConn = new OleDbConnection("Provider=Microsoft.Project.OLEDB.11.0;Project Name=C:\\Program Files\\Microsoft Office\\Visio11\\Samples\\1033\\TIMELINE.MPP");
OleDbDataReader projReader;
OleDbCommand cmd = new OleDbCommand("SELECT * FROM Tasks", projConn);
projConn.Open();
projReader = cmd.ExecuteReader();
int fieldCount = projReader.FieldCount;
Debug.WriteLine("Start!");
while(projReader.Read())
{
Debug.WriteLine("-------------------------Start Item!");
string unableToRead = "";
for(int x = 0; x < fieldCount; x ++)
{
try
{
Debug.Write(projReader[x].GetType().ToString() + " (" + x + ") : ");
}
catch(Exception)
{
unableToRead += x.ToString() + " : ";
}
}
Debug.WriteLine("");
Debug.WriteLine("Unable to read: " + unableToRead);
Debug.WriteLine("-------------------------End Item!");
}
Debug.WriteLine("Done!");
projReader.Close();
projConn.Close();
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}

I can get the information I am trying to obtain by using the automation tools that are built into Office, but that is truely a pain in the ass and MS says in their docs that it is not a good idea, so I'm trying to be a good citizen and avoid it.

grrrrr........... Why hasn't Project gone to the XML formats that Word and other MS Office products have gone to?

0 Comments:

Post a Comment

<< Home