G
Guest
Dear NG,
I am making progress processing trees. I can "span" a tree if I make wise
use of the C# stack methods, push() and pop(). What I want to place on the
stack are rows from a data table. The columns (about a dozen) have string,
decimal, and int data in them. The following code concatinates (tab
delimited) a row and places it on the stack sucessfully. Is there any way to
do this without packing and unpacking the columns into and out of a string?
In other words, place the whole row on the stack? Thanks, Bob
private void button1_Click(object sender, System.EventArgs e)
{
SqlConnection mcs3Connection = MCS3_DB.GetConnection();
string selectStmt = "SELECT * FROM ProdStrt WHERE ps_parent = '500-000'
ORDER BY ps_parent";
SqlCommand selectCmd = new SqlCommand(selectStmt, mcs3Connection);
SqlDataAdapter dataAdapter = new SqlDataAdapter(selectCmd);
DataSet dataSet = new DataSet();
dataAdapter.Fill(dataSet, "PS"); //dataSet has 1 DataTable IM
// Moving through a table:
int nRows = dataSet.Tables["PS"].Rows.Count;
string strRows = nRows.ToString();
Stack myStack = new Stack();
string strTemp;
MessageBox.Show("Number of rows: " + strRows);
for (int i = 0; i < nRows; i++)
{
strTemp = dataSet.Tables["PS"].Rows["ps_component"].ToString() + "\t" +
dataSet.Tables["PS"].Rows["ps_parent"].ToString();
myStack.Push(strTemp);
MessageBox.Show("entry: " + strTemp, "Info");
}
for (int i = 0; i < nRows; i++)
{
strTemp = (string) myStack.Pop();
MessageBox.Show("exit: " + strTemp, "Info");
}
}
I am making progress processing trees. I can "span" a tree if I make wise
use of the C# stack methods, push() and pop(). What I want to place on the
stack are rows from a data table. The columns (about a dozen) have string,
decimal, and int data in them. The following code concatinates (tab
delimited) a row and places it on the stack sucessfully. Is there any way to
do this without packing and unpacking the columns into and out of a string?
In other words, place the whole row on the stack? Thanks, Bob
private void button1_Click(object sender, System.EventArgs e)
{
SqlConnection mcs3Connection = MCS3_DB.GetConnection();
string selectStmt = "SELECT * FROM ProdStrt WHERE ps_parent = '500-000'
ORDER BY ps_parent";
SqlCommand selectCmd = new SqlCommand(selectStmt, mcs3Connection);
SqlDataAdapter dataAdapter = new SqlDataAdapter(selectCmd);
DataSet dataSet = new DataSet();
dataAdapter.Fill(dataSet, "PS"); //dataSet has 1 DataTable IM
// Moving through a table:
int nRows = dataSet.Tables["PS"].Rows.Count;
string strRows = nRows.ToString();
Stack myStack = new Stack();
string strTemp;
MessageBox.Show("Number of rows: " + strRows);
for (int i = 0; i < nRows; i++)
{
strTemp = dataSet.Tables["PS"].Rows["ps_component"].ToString() + "\t" +
dataSet.Tables["PS"].Rows["ps_parent"].ToString();
myStack.Push(strTemp);
MessageBox.Show("entry: " + strTemp, "Info");
}
for (int i = 0; i < nRows; i++)
{
strTemp = (string) myStack.Pop();
MessageBox.Show("exit: " + strTemp, "Info");
}
}