如何在C#中基于checkboxex从sql中选择数据 [英] how to select data from sql on the basis of checkboxex in C#

查看:95
本文介绍了如何在C#中基于checkboxex从sql中选择数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 我有3个年份的复选框,2008、2009、2010
我在sql server中有一个数据库,我必须生成报告,例如员工的年龄百分比,明智的员工等,
我必须根据这些复选框生成相同的报告,一个,两个或三个值应生成相同的报告,
我应该/应该做些什么

解决方案

将所选年份作为逗号分隔的值传递给您的存储过程,例如"2008,2009,2010".在存储过程中,像这样在WHERE子句中使用此输入构建动态查询

 '  WHERE MyYear IN(' + ' 

Pass the selected years as comma separated values to your stored procedures like this ''2008,2009,2010''. In the Stored Procedure, build a dynamic query using this input in the WHERE clause like this

' WHERE MyYear IN (' + @SelectedYears + ')'


i have a logic , and asking about how can we dolike a session variable,
if year is 2008, than it will load database data into temporary database table and calculate reports from that data, and so on for the 2009 and 2010


select * from table where year in (2008,2009.2010) pass the year at run time when u write query


这篇关于如何在C#中基于checkboxex从sql中选择数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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