如何在ASP.NET中使用内联查询 [英] How to use inline query in asp.net

查看:58
本文介绍了如何在ASP.NET中使用内联查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个桌子
package(pac_id,package_bid,package_price)和tbl_bid(bid_id,lid,available_bid)

我想做这样..
当用户选择任何包裹,然后选择包裹的出价时,将其添加到available_bid
嘻嘻,我用这样的查询...

I have two table
package(pac_id,package_bid,package_price) and tbl_bid(bid_id,lid,available_bid)

and i want to make like this..
when user select any package and then selected package''s bid add into available_bid
hee i use like this query...

("update tbl_bid set Availablebid = Availablebid + (select Package_Price from package where pac_id = e.commandargument,con) where l_id=1", con);


it will show error like (Incorrect syntax near ',')


我将包表数据绑定到数据列表中...

在此先感谢


i bind package table data in datalist...

thanks in advance

推荐答案

您的查询中有错误....

Error is in your query....

("update tbl_bid set Availablebid = Availablebid + (select Package_Price from package where pac_id = e.commandargument,con) where l_id=1", con);



您已经编写了两个连接,一个在选择查询之后,另一个在总查询之后...

但是您应该在选择查询后删除con,这会引起逗号(,)...后的语法问题.



You have written two connections, one after select query another after total query...

But you should remove the con after select query, which is causing the problem syntax after comma (,)...


您在语句中使用了两次con对象.
删除第一个con对象.

希望您能找到解决方案.

如有其他疑问,请随时进行.
you have used con object twice in the statement.
remove first con object.

Hope you will get the solution.

Feel free if any other doubt.


您正在sql查询中使用"Convert.ToInt32()",但这不是sql内置函数,它在c#中.所以,你可以做...

You are using "Convert.ToInt32()" inside sql query, but that is not a sql inbuilt function, it is in c#. So, you can do like...

int pac_id = Convert.ToInt32(e.CommandArgument);





string sqlQuery = "update tbl_bid 
set available_bid = available_bid + (select Package_Price from package where pac_id = '" + pac_id + "') 
where lid = 1";

SqlCommand cmd = new SqlCommand(sqlQuery, con);



确保所有列名都是正确的,并且"available_bid"和"Package_Price"应具有相同的数据类型.

当您第一次问类似...的问题时,我已经创建了表和列,就像您发布的一样.



Make sure all your column names are correct and "available_bid" and "Package_Price" should have same data type.

I have created tables and columns as you posted when you first asked the question like ...

package(pac_id,package_bid,package_price) and tbl_bid(bid_id,lid,available_bid)



该查询在我的情况下有效..



And the query worked in my case..


这篇关于如何在ASP.NET中使用内联查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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