在Asp.net中为什么会出现阅读器关闭时 Read 的尝试无效
using(cmd=newSqlCommand("select*from购物车视图where会员名=@name",con)){cmd.Parameters.AddWith...
using (cmd = new SqlCommand("select * from 购物车视图 where 会员名=@name ", con))
{
cmd.Parameters.AddWithValue("@name", Application.Count.ToString());
con.Open();
SqlDataReader sr = cmd.ExecuteReader();
con.Close ();
while (sr .Read ())
{
Double pirce=(Double )sr["价格"];
int number = (Int32)sr["数量"];
Double sum = 0;
sum += pirce * number ;
txtatils.Text = sum.ToString();
}
sr.Close();
} 展开
{
cmd.Parameters.AddWithValue("@name", Application.Count.ToString());
con.Open();
SqlDataReader sr = cmd.ExecuteReader();
con.Close ();
while (sr .Read ())
{
Double pirce=(Double )sr["价格"];
int number = (Int32)sr["数量"];
Double sum = 0;
sum += pirce * number ;
txtatils.Text = sum.ToString();
}
sr.Close();
} 展开
2011-04-26
展开全部
using (cmd = new SqlCommand("select * from 购物车视图 where 会员名=@name ", con))
{
cmd.Parameters.AddWithValue("@name", Application.Count.ToString());
con.Open();
SqlDataReader sr = cmd.ExecuteReader();
while (sr .Read ())
{
Double pirce=(Double )sr["价格"];
int number = (Int32)sr["数量"];
Double sum = 0;
sum += pirce * number ;
txtatils.Text = sum.ToString();
}
sr.Close();
con.Close ();
}
{
cmd.Parameters.AddWithValue("@name", Application.Count.ToString());
con.Open();
SqlDataReader sr = cmd.ExecuteReader();
while (sr .Read ())
{
Double pirce=(Double )sr["价格"];
int number = (Int32)sr["数量"];
Double sum = 0;
sum += pirce * number ;
txtatils.Text = sum.ToString();
}
sr.Close();
con.Close ();
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询