OleDbConnection conn = new OleDbConnection(connectionStr);
conn.Open();
string zprice = null;
string cname = Session["cname"].ToString();
string sql = "SELECT SUM(gsprice) AS zj FROM cart WHERE csname=" + cname;
OleDbCommand cmd = new OleDbCommand(sql, conn);
OleDbDataReader reader = cmd.ExecuteReader();
if (reader.Read())
{
zprice = reader["zj"].ToString();
}
reader.Close();
conn.Close();
Label1.Text = zprice.ToString();
Session["zj"] = zprice;
Response.Redirect("order.aspx");
提示:至少一个参数没有被指定值。
说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.Data.OleDb.OleDbException: 至少一个参数没有被指定值。
源错误:
行 22:
行 23: OleDbCommand cmd = new OleDbCommand(sql, conn);
行 24: OleDbDataReader reader = cmd.ExecuteReader();
行 25: if (reader.Read())
行 26: {
我想将总值传到下个页面,但是到24行就报错
1 个解决方案
#1
string sql = "SELECT SUM(gsprice) AS zj FROM cart
WHERE csname='" + cname +"' ";
#1
string sql = "SELECT SUM(gsprice) AS zj FROM cart
WHERE csname='" + cname +"' ";