如何在使用asp.net查询之间编写sql server 2005 [英] how to write sql server 2005 between query for the follwing using asp.net

查看:62
本文介绍了如何在使用asp.net查询之间编写sql server 2005的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  int  actualcost = Convert.ToInt32(dt_sms.Rows [ 0 ] [  Cost]。ToString()); 
int bargaincost = actualcost - 200 ;
string sql_cust = string .Format( SELECT CustomerMaster.CustomerName,CustomerMaster.Phoneno,CustomerMaster.EmailId,CostMaster.Cost,RequestMaster.SetCost FROM CostMaster INNER JOIN ProductMaster ON CostMaster.ProductId = ProductMaster.ProductId INNER JOIN RequestMaster ON CostMaster.CostId = RequestMaster.CostId INNER JOIN CustomerMaster ON RequestMaster.CustomerId = CustomerMaster.CustomerId,其中CostMaster.AgentId ='{0}'和ProductMaster.ProductId ='{1}'和RequestMaster.SetCost介于realcost和bargaincost之间





以上是我的代码。实际成本和讨价还价不在表中。如何编写此查询。请帮助我

解决方案

按以下顺序修改您的查询。



string .format(SELECT CustomerMaster.CustomerName,CustomerMaster.Phoneno,CustomerMaster.EmailId,CostMaster.Cost,RequestMaster.SetCost FROM CostMaster INNER JOIN ProductMaster ON CostMaster.ProductId = ProductMaster.ProductId INNER JOIN RequestMaster ON CostMaster.CostId = RequestMaster.CostId INNER JOIN CustomerMaster ON RequestMaster.CustomerId = CustomerMaster.CustomerId,其中CostMaster.AgentId ='{0}'和ProductMaster.ProductId ='{1}'和RequestMaster.SetCost介于{2}和{3}之间,arg1,arg2,actualcost,bargaincost )

int actualcost = Convert.ToInt32(dt_sms.Rows[0]["Cost"].ToString());
                   int bargaincost = actualcost - 200;
                   string sql_cust= string.Format("SELECT CustomerMaster.CustomerName, CustomerMaster.Phoneno, CustomerMaster.EmailId, CostMaster.Cost, RequestMaster.SetCost FROM CostMaster INNER JOIN  ProductMaster ON CostMaster.ProductId = ProductMaster.ProductId INNER JOIN RequestMaster ON CostMaster.CostId = RequestMaster.CostId INNER JOIN CustomerMaster ON RequestMaster.CustomerId = CustomerMaster.CustomerId where CostMaster.AgentId='{0}' and ProductMaster.ProductId='{1}' and RequestMaster.SetCost Between actualcost and bargaincost")



Above is my code. actualcost and bargaincost are not in table. how to write this query.please help me

解决方案

Modify your query in following order.

string.format("SELECT CustomerMaster.CustomerName, CustomerMaster.Phoneno, CustomerMaster.EmailId, CostMaster.Cost, RequestMaster.SetCost FROM CostMaster INNER JOIN ProductMaster ON CostMaster.ProductId = ProductMaster.ProductId INNER JOIN RequestMaster ON CostMaster.CostId = RequestMaster.CostId INNER JOIN CustomerMaster ON RequestMaster.CustomerId = CustomerMaster.CustomerId where CostMaster.AgentId='{0}' and ProductMaster.ProductId='{1}' and RequestMaster.SetCost Between {2} and {3}", arg1, arg2, actualcost, bargaincost)


这篇关于如何在使用asp.net查询之间编写sql server 2005的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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