我想分别在两个字符串中添加2行的总和,请帮忙
我的功能编码所有参数都很好但仍然出错
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]);
}
}
这里的错误
+ base {"Invalid attempt to read when no data is present."} System.Exception {System.InvalidOperationException}