i want to add sum of 2 rows into two strings respectively please help
its my function's coding all parameters are well n good but still getting an error
public void temporderentry(SqlConnection conn,SqlCommand comd)
{
string sql = "select SUM(productQuaintyInOrder) ,SUM(cost) from OrderProduct where orderID = " + oid; //oid is defined
if (conn.State != ConnectionState.Open)
{
conn.Open();
}
comd = new SqlCommand(sql, conn);
SqlDataReader dr = comd.ExecuteReader();
while (dr.HasRows)
{
cart = Convert.ToInt32(dr[0]);
totalpayment = Convert.ToInt32(dr[1]);
}
}
here the error
+ base {"Invalid attempt to read when no data is present."} System.Exception {System.InvalidOperationException}