VS2005中TableAdapter中实现动态查询并使用LIKE的方法整理
2011-07-18 15:45
821 查看
VS2005中TableAdapter中实现动态查询并使用LIKE的方法整理
TableAdapter FILLBY 参数去空格问题
发现带入参数有问题 有空格
(解决思路是将 LIKE 放到语句里面)
这里
StringBuilder p =new StringBuilder();
p.Append("%");
p.Append ( textBox1.Text.ToString().Trim());
p.Append ("%");
在tableAdapter中配置语句
SELECT ProdCode, BarCode, ProdName, DepCode, ClsCode, SupCode, SeatCode,
BrandCode, Spec, Unit, ProdAdr, ProdType, ScaleType, Price, OPrice, OutOPrice,
VipPrice1, VipPrice2, VipPrice3, WPrice, PSPrice, KCCount, Cost, OutCost, Total, OTax,
STax, ProdMemo1, ProdMemo2, ShopDepCode, EditDate, EditUser, PControl,
AidCode, TakeRate, GatherRate, NewDate, NewUser, MadeCode, BDscCode
FROM bak_product1
WHERE (BarCode LIKE @p)
参数 p
TableAdapter FILLBY 参数去空格问题
发现带入参数有问题 有空格
(解决思路是将 LIKE 放到语句里面)
if (textBox1.Text.Length == 0 || textBox1.Text.ToString().Trim()=="" ) { this.kgtLink2008DataSet.bak_product1.Clear(); this.bak_product1TableAdapter.Fill(this.kgtLink2008DataSet.bak_product1); this.dataGridView1.DataSource = bakproduct1BindingSource; } else { this.kgtLink2008DataSet.bak_product1.Clear(); StringBuilder p =new StringBuilder(); p.Append("%"); p.Append ( textBox1.Text.ToString().Trim()); p.Append ("%"); this.bak_product1TableAdapter.FillBy(this.kgtLink2008DataSet.bak_product1, p.ToString()); this.dataGridView1.DataSource = bakproduct1BindingSource; }
这里
StringBuilder p =new StringBuilder();
p.Append("%");
p.Append ( textBox1.Text.ToString().Trim());
p.Append ("%");
在tableAdapter中配置语句
SELECT ProdCode, BarCode, ProdName, DepCode, ClsCode, SupCode, SeatCode,
BrandCode, Spec, Unit, ProdAdr, ProdType, ScaleType, Price, OPrice, OutOPrice,
VipPrice1, VipPrice2, VipPrice3, WPrice, PSPrice, KCCount, Cost, OutCost, Total, OTax,
STax, ProdMemo1, ProdMemo2, ShopDepCode, EditDate, EditUser, PControl,
AidCode, TakeRate, GatherRate, NewDate, NewUser, MadeCode, BDscCode
FROM bak_product1
WHERE (BarCode LIKE @p)
参数 p
相关文章推荐
- VS2005中TableAdapter中实现动态查询并使用LIKE的方法整理
- SpringBoot中使用Spring Data Jpa 实现简单的动态查询的两种方法
- QBC常用限定方法,使用QBC实现动态查询 ,Restrictions
- SpringBoot中使用Spring Data Jpa 实现简单的动态查询的两种方法
- baseadapter.getItemId的使用方法:实现listview筛选、动态删除
- 使用反射实现根据名称动态创建窗体的几种方法。
- [转]Linq to sql 实现多条件的动态查询(方法二)
- 动态方法调用和使用通配符实现类似struts1.x的dispatchAction功能
- 使用表达式树动态构建Linq查询条件来实现单个实体动态查询
- 构造使用IN子句的动态Transact-SQL方法进行编号查询
- 实现<table>标签的动态新增和后台接受<table>标签的方法
- TABLE CONTROL使用方法(待整理)
- 使用js实现对table的动态添加、删除和更新
- MonogDB查询、修改等使用方法整理
- Thinkphp使用mongodb数据库实现多条件查询方法
- JS实现动态生成html table表格的方法分析
- 使用ADF-BC 实现查询功能之九:重写getCriteriaItemClause方法设置Criteria中的变量
- 编写的vs2005水晶报表程序在vs2008下正常使用的一些实现方法
- 使用RenderControl方法实现动态加载用户控件
- MySQL使用like查询中文不准确的解决方法