如何通过传递具有条件的查询从数据网格视图中的访问获取数据 [英] How Do I Obtain The Data From Access In Data Gridview By Passing A Query With Where Conditions

查看:73
本文介绍了如何通过传递具有条件的查询从数据网格视图中的访问获取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有C#windows应用程序的Access 2007数据库我创建了一个查询,使用like来查找表payment_voucher中的聚会名称,我也希望通过输入凭证金额来查找凭证



我的查询如下:

I am using Access 2007 database with C# windows application I create a query to find the party names from the table payment_voucher using like and i also want to find the vouchers by entering voucher amount

My query is like following

select voucher_date as VCDate,voucher_code as VoucherNo,receiver_name as PartyName,expense_head_name as Purpose,voucher_amount as Amount from payment_voucher where voucher_code='" + txt_vc_number.Text + "' or receiver_name Like '" + txt_party_name.Text + "' or voucher_amount='" + amt + "'





但是如果我在聚会名称文本框中输入R,它就不会显示给我的记录,当我在金额文本框中输入金额时它也显示错误



它显示错误



But it does not shows the record to me if i entered R in party name text box and it also shows error when i entered amount in a amount text box

it shows the error that

Data type mismatch in criteria expression.





请帮我删除此错误



Please help me remove this error

推荐答案

尝试删除单个引用 amt 变量:

Try removing the single quote around the amt variable:
select voucher_date as VCDate,voucher_code as VoucherNo,receiver_name as PartyName,expense_head_name as Purpose,voucher_amount as Amount from payment_voucher where voucher_code='" + txt_vc_number.Text + "' or receiver_name Like '" + txt_party_name.Text + "' or voucher_amount=" + amt + "

这篇关于如何通过传递具有条件的查询从数据网格视图中的访问获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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