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
Can someone help me how to read MS Project files (mpp) via .net (C# or VB).
Thank you
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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#)
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=Micros oft.Projec t.OLEDB.11 .0;PROJECT NAME=" + textBox1.Text, null, null, 0);
rs.Open(textBox2.Text, conn, ADODB.CursorTypeEnum.adOpe nForwardOn ly, ADODB.LockTypeEnum.adLockR eadOnly, (int) ADODB.CommandTypeEnum.adCm dText);
for(int x = 0; x < rs.Fields.Count; x ++)
{
dt.Columns.Add(new DataColumn(rs.Fields[x].Na me, rs.Fields[x].Value.GetType ()));
Debug.WriteLine("(" + rs.Fields[x].Name + ") " + rs.Fields[x].Value.GetType ().ToStrin g());
}
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.ToStrin g());
this.Text = "Error, run in debug mode to see error in output window.";
}
try
{
DataTable dt = new DataTable();
ADODB.ConnectionClass conn = new ADODB.ConnectionClass();
ADODB.RecordsetClass rs = new ADODB.RecordsetClass();
conn.CommandTimeout = 30;
conn.Open("Provider=Micros
rs.Open(textBox2.Text, conn, ADODB.CursorTypeEnum.adOpe
for(int x = 0; x < rs.Fields.Count; x ++)
{
dt.Columns.Add(new DataColumn(rs.Fields[x].Na
Debug.WriteLine("(" + rs.Fields[x].Name + ") " + rs.Fields[x].Value.GetType
}
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.ToStrin
this.Text = "Error, run in debug mode to see error in output window.";
}
ASKER
Helped . But wasn;t exact solution.
http://mpxj.sourceforge.net/