Link to home
Start Free TrialLog in
Avatar of Aanvik
Aanvik

asked on

Reading MPP Files

Hi
Can someone help me how to read MS Project files (mpp) via .net (C# or VB).

Thank you
ASKER CERTIFIED SOLUTION
Avatar of Senz79
Senz79
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
For more detail follow this link

http://mpxj.sourceforge.net/
Avatar of Aanvik
Aanvik

ASKER

I got both these when I googled it but its not working.

http://mpxj.sourceforge.net/ do you have any sample for this (in C#)
Hi

try
{
DataTable dt = new DataTable();
ADODB.ConnectionClass conn = new ADODB.ConnectionClass();
ADODB.RecordsetClass rs = new ADODB.RecordsetClass();
conn.CommandTimeout = 30;
conn.Open("Provider=Microsoft.Project.OLEDB.11.0;PROJECT NAME=" + textBox1.Text, null, null, 0);
rs.Open(textBox2.Text, conn, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockReadOnly, (int) ADODB.CommandTypeEnum.adCmdText);
for(int x = 0; x < rs.Fields.Count; x ++)
{
dt.Columns.Add(new DataColumn(rs.Fields[x].Name, rs.Fields[x].Value.GetType()));
Debug.WriteLine("(" + rs.Fields[x].Name + ") " + rs.Fields[x].Value.GetType().ToString());
}
while(!rs.EOF)
{
DataRow dr = dt.NewRow();
for(int x = 0; x < rs.Fields.Count; x ++)
{
dr[rs.Fields[x].Name] = rs.Fields[x].Value;
}
dt.Rows.Add(dr);
rs.MoveNext();
}
conn.Close();
dataGrid1.DataSource = dt;
this.Text = "Eric brings you the examples that you will not find in the MS docs :)";
}
catch(Exception ex)
{
Debug.WriteLine(ex.ToString());
this.Text = "Error, run in debug mode to see error in output window.";
}
Avatar of Aanvik

ASKER

Helped . But wasn;t exact solution.