March 27, 2004

MS Datashaping Example for Project 2003

Here is an MS Datashaping example that goes along with the previous few posts:

ADODB.ConnectionClass conn = new ADODB.ConnectionClass();
ADODB.RecordsetClass rs = new ADODB.RecordsetClass();
conn.CommandTimeout = 30;
conn.Open("Provider=MSDataShape.1; Extended Properties='Project Name=d:\\Sample Microsoft Project.mpp';Persist Security Info=False; Data Source=''; User ID='';Initial Catalog=d:\\Sample Microsoft Project.mpp; Data Provider=MICROSOFT.PROJECT.OLEDB.11.0", null, null, 0);
rs.Open("SHAPE {SELECT Project FROM Project} APPEND ({SELECT Project, TaskUniqueId FROM Tasks} AS childRows RELATE 'Project' TO 'Project')", conn, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockReadOnly, (int) ADODB.CommandTypeEnum.adCmdText);
Debug.WriteLine("Start!!!");
while(!rs.EOF)
{
for(int x = 0; x < rs.Fields.Count; x ++)
{
Debug.Write(rs.Fields[x].Name.ToString() + " : ");
if(rs.Fields[x].Name.ToString() == "childRows")
{
ADODB._Recordset rs2 = (ADODB._Recordset) rs.Fields[x].Value;
while(!rs2.EOF)
{
for(int i = 0; i < rs2.Fields.Count; i ++)
{
Debug.Write(rs2.Fields[i].Name.ToString() + " : ");
}
rs2.MoveNext();
}
}
}
rs.MoveNext();
}
Debug.WriteLine("");
Debug.WriteLine("End!!!");
conn.Close();

0 Comments:

Post a Comment

<< Home