asp.net c#减少产品数量 [英] asp.net c# reduce quantity of a product

查看:101
本文介绍了asp.net c#减少产品数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我正在实施一个asp.net c#网站,我正在使用这段代码来减少
$ b当用户按下按钮完成(或结账)时,$ b正确的产品数量

----------------------- -----------

 SqlConnection con =  new  SqlConnection(ConfigurationManager。 ConnectionStrings [  ConnectionString]。ToString()); 
string aSQL = 更新产品设定数量=数量 - + Request.QueryString [ quant] + 其中Id = + Request.QueryString [ < span class =code-string> Id];
尝试
{
con.Open();
SqlCommand cmd = new SqlCommand(aSQL,con);
SqlDataReader reader = cmd.ExecuteReader();
reader.Read();
DataTable dataTable = new DataTable();
dataTable.Load(读者);
}
最后
{
con.Close();
}



------------------------- ----------

我的问题是它减少了正确产品的数量但总是(x2)

i无法理解为什么?这是一个非常奇怪的问题,

任何帮助解决这个问题我将不胜感激或任何其他相关的解决方案使用?



thnx提前!

Jason

解决方案

试试这个

 SqlConnection con = new SqlConnection(ConfigurationManager。的ConnectionStrings [ 的ConnectionString]的ToString()); 
string aSQL =UPDATE products set quantity = quantity-1+ Request.QueryString [quant] +Where Id =+ Request.QueryString [Id];









 SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings [ConnectionString]。ToString()); 
string aSQL =UPDATE products set quantity = - quantity+ Request.QueryString [quant] +Where Id =+ Request.QueryString [Id];



第一个工作我有相同的项目库管理,在发出一本书后我必须通过bookid.try减少数量并让我知道


杰森。你使用任何文本框?


Hi,

I'm implementing an asp.net c# web site and i'm using this code in order to reduce the
correct quantity of a product when the user press the button finish (or checkout)
"----------------------------------"

SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString());
       string aSQL = "UPDATE products set quantity=quantity-" + Request.QueryString["quant"] + "Where Id=" + Request.QueryString["Id"];
       try
       {
           con.Open();
           SqlCommand cmd = new SqlCommand(aSQL, con);
           SqlDataReader reader = cmd.ExecuteReader();
           reader.Read();
           DataTable dataTable = new DataTable();
           dataTable.Load(reader);
       }
       finally
       {
           con.Close();
       }


"-----------------------------------"
my issue that it reduces the quantity from the correct product but always (x2)
i can't understand why ? this is a very strange problem,
any help to fix this issue i will be grateful or any other relative solution to use?

thnx in advance!
Jason

解决方案

try this

SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString());
       string aSQL = "UPDATE products set quantity=quantity-1" + Request.QueryString["quant"] + "Where Id=" + Request.QueryString["Id"];



or

SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString());
       string aSQL = "UPDATE products set quantity=--quantity" + Request.QueryString["quant"] + "Where Id=" + Request.QueryString["Id"];


the first one is working i have same project library management where after issuing a book i have to reduce quantity by bookid.try and let me know


Jason. R you using any textbox?


这篇关于asp.net c#减少产品数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆