prblem与查询有关 [英] prblem related to query

查看:137
本文介绍了prblem与查询有关的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,

我正在报告,我有一个问题,当我们从组合框中选择员工并运行报告时,它必须显示特定的员工。

当我没有选择任何内容并运行报告时,所有来自数据库的员工都必须显示在report.so我应该写什么样的查询。

解决方案

你还没有提到任何代码所以我们对你的数据有了很好的了解。但凭借这些知识,一个示例查询可能会帮助您开始。



您需要编写一个选择查询,其中where条件可以过滤掉匹配的员工姓名。如果过滤器为空则选择全部。

例如:

 选择 * < span class =code-keyword>来自 employeeTable; //此查询将返回 全部 表中的行 employeeTable 

选择 * 来自 employeeTable where EmployeeName = txtFromCombo; //这将 return 匹配EmployeeName的行等于 值txtFromCombo 其中 txtFromCombo 一个字符串。


//你可以得到这样的组合值



 如果(组合。文字!=  请选择&& ; combo。 Text !=  全部){
MessageBox.Show( 员工ID为 + cboItemName.SelectedValue.ToString ());
}
else
{
MessageBox.Show( No Employee Select);
}
< / pre>





这可以帮助你


< blockquote>对于您在if子句中写入条件的特定员工以及当您想要所有员工信息时,您在其他条款中编码正常选择查询.............


Hello friends,
I am making report and I have one issue such that when we selecting employee from combobox and run the report then it must show particular employee.
And when I select nothing and run report then all employee from database must be display on report.so what kind of query I should write.

解决方案

you havent mentioned any code so we have fair idea of your data''s. but with that knowledge a sample query may be help you to get going.

you need to write a select query with where condition to filter out the matching employee name. if filter is empty select all.
eg:

select * from employeeTable; // this query will return all the rows inside the table employeeTable

select * from employeeTable where EmployeeName = txtFromCombo; // this will return row that matching the EmployeeName equals to the value txtFromCombo where txtFromCombo is a string.


//you can get the combo value in this way

if (combo.Text  != "Please Select" && combo.Text  != "All"){
MessageBox.Show("Employee Id is "+ cboItemName.SelectedValue.ToString());
}
else
{
MessageBox.Show("No Employee Select");
}
</pre>



May this help you


for particular Employee you write where condition in if clause and when you want to all employee information you code normal select query in else clause.............


这篇关于prblem与查询有关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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