wilerk
05-30-2006, 10:23 AM
Hi There,
I'm pretty new to programming and wonder if somebody wouldn't mind assisting me with a little problem I'm facing. I have an Array filled with data from a SqlDataReader and I would like to add the values to a total value. The output is for example 5000 and 10000 and I would like to see this added to 15000. Here is what I have so far to check if I am getting anything into my Array:
SqlConnection sqlConn = new SqlConnection("TraLaLaLaaaaa");
string getinvoiceID = Request.QueryString["invoiceID"];
string slcStmt = "Select NettPrice From tblAddProd WHERE invoiceID = " + getinvoiceID;
SqlCommand sqlCmd = new SqlCommand(slcStmt, sqlConn);
sqlCmd.Connection.Open();
ArrayList arNettPrice = new ArrayList();
SqlDataReader sqlReader = sqlCmd.ExecuteReader();
while (sqlReader.Read())
{
object[] values = new object[sqlReader.FieldCount];
sqlReader.GetValues(values);
arNettPrice.Add(values);
}
sqlReader.Close();
sqlConn.Close();
foreach(object[] row in arNettPrice) {
foreach(object column in row) {
lblSubTots.Text += column.ToString() + "<br>";
}
}
Thanks in advance,
Xander
I'm pretty new to programming and wonder if somebody wouldn't mind assisting me with a little problem I'm facing. I have an Array filled with data from a SqlDataReader and I would like to add the values to a total value. The output is for example 5000 and 10000 and I would like to see this added to 15000. Here is what I have so far to check if I am getting anything into my Array:
SqlConnection sqlConn = new SqlConnection("TraLaLaLaaaaa");
string getinvoiceID = Request.QueryString["invoiceID"];
string slcStmt = "Select NettPrice From tblAddProd WHERE invoiceID = " + getinvoiceID;
SqlCommand sqlCmd = new SqlCommand(slcStmt, sqlConn);
sqlCmd.Connection.Open();
ArrayList arNettPrice = new ArrayList();
SqlDataReader sqlReader = sqlCmd.ExecuteReader();
while (sqlReader.Read())
{
object[] values = new object[sqlReader.FieldCount];
sqlReader.GetValues(values);
arNettPrice.Add(values);
}
sqlReader.Close();
sqlConn.Close();
foreach(object[] row in arNettPrice) {
foreach(object column in row) {
lblSubTots.Text += column.ToString() + "<br>";
}
}
Thanks in advance,
Xander