P
pei_world
can anyone help me with these problem, code written correctly except those
with * mark.
//==========================================================================
===============================
//recursive function defined for print nodes
private void nodePrint(TreeNode rootNode,string parentidstr,SqlDataAdapter
sqlDANode,DataSet tmpDS)
{
bool printed=false;
try
{
tmpDS.Clear();
sqlDANode.SelectCommand.CommandText="SELECT parentid,childid FROM
relation WHERE parentid="+parentidstr;
sqlDANode.Fill(tmpDS,"relation");
//MessageBox.Show(tmpDS.Tables.Count.ToString(),"try",MessageBoxButtons.OK,M
essageBoxIcon.Asterisk);
if(tmpDS.Tables["relation"].Rows.Count>0)
{
string[] tmpArray = new string[tmpDS.Tables["relation"].Rows.Count];
int i=0;
foreach(DataRow nodeRow in tmpDS.Tables["relation"].Rows)
{
if(i<tmpDS.Tables["relation"].Rows.Count)
{
tmpArray = nodeRow["childid"].ToString();
i=i+1;
}
}
if(printed==false)
{
TreeNode newNode =
rootNode.Nodes.Add(tmpDS.Tables["relation"].Rows[0]["parentid"].ToString());
printed=true;
}
else
{
TreeNode newNode = rootNode;
}
for(int k=0; k<i; k++)
{
parentidstr = tmpArray[k];
nodePrint(newNode,parentidstr,sqlDANode,tmpDS); //************* Error
if(printed!=true)
{
newNode.Nodes.Add(tmpArray[k]);//2 //*********** Error
}
}
}
else
{
return;
}
}
catch(Exception E)
{
MessageBox.Show(E.ToString(),"try",MessageBoxButtons.OK,MessageBoxIcon.Aster
isk);
}
}
//==========================================================================
=====================
Error output in VS.net:
1. The name 'newNode' does not exist in the class or namespace
2. The type or namespace name 'newNode' could not be found (are you missing
a using directive or an assembly reference?)
but I did create newNode object a few lines before.
with * mark.
//==========================================================================
===============================
//recursive function defined for print nodes
private void nodePrint(TreeNode rootNode,string parentidstr,SqlDataAdapter
sqlDANode,DataSet tmpDS)
{
bool printed=false;
try
{
tmpDS.Clear();
sqlDANode.SelectCommand.CommandText="SELECT parentid,childid FROM
relation WHERE parentid="+parentidstr;
sqlDANode.Fill(tmpDS,"relation");
//MessageBox.Show(tmpDS.Tables.Count.ToString(),"try",MessageBoxButtons.OK,M
essageBoxIcon.Asterisk);
if(tmpDS.Tables["relation"].Rows.Count>0)
{
string[] tmpArray = new string[tmpDS.Tables["relation"].Rows.Count];
int i=0;
foreach(DataRow nodeRow in tmpDS.Tables["relation"].Rows)
{
if(i<tmpDS.Tables["relation"].Rows.Count)
{
tmpArray = nodeRow["childid"].ToString();
i=i+1;
}
}
if(printed==false)
{
TreeNode newNode =
rootNode.Nodes.Add(tmpDS.Tables["relation"].Rows[0]["parentid"].ToString());
printed=true;
}
else
{
TreeNode newNode = rootNode;
}
for(int k=0; k<i; k++)
{
parentidstr = tmpArray[k];
nodePrint(newNode,parentidstr,sqlDANode,tmpDS); //************* Error
if(printed!=true)
{
newNode.Nodes.Add(tmpArray[k]);//2 //*********** Error
}
}
}
else
{
return;
}
}
catch(Exception E)
{
MessageBox.Show(E.ToString(),"try",MessageBoxButtons.OK,MessageBoxIcon.Aster
isk);
}
}
//==========================================================================
=====================
Error output in VS.net:
1. The name 'newNode' does not exist in the class or namespace
2. The type or namespace name 'newNode' could not be found (are you missing
a using directive or an assembly reference?)
but I did create newNode object a few lines before.