本文介绍了如何将datetime值作为参数传递以从数据表中选择行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 大家好,我有一个名为shifttable的数据表。我希望通过传递datetime参数找出Rows,但它会产生与转换失败之前相同的错误。我需要的是如何传递数据表的参数。请给我帮忙。 这里是我的代码: DateTime daterange = DateTime.now DataRow [] foundrows = shifttable.Select( EMPLOYEEID ='+ empid.ToString()+'和STARTDATE< ='+ daterange +'和ENDDATE> ='+ daterange +'); 在这种情况下,daterange的值是2017-11-23 8:06:34 nm。这就是我的代码生成错误的原因。所以我应该参数化我的代码。任何帮助请 我尝试过: DateTime daterange = DateTime.now DataRow [] foundrows = shifttable.Select(EMPLOYEEID ='+ empid.ToString()+'和STARTDATE< ='+ daterange +'和ENDDATE> =' + daterange +'); Hi every one, I have datatable named as shifttable. I want to find out Rows by passing datetime parameters but it generate the same error as before that is conversion failed . what I need is how to pass parameter for the datatable. may I gate help please.here is my code:DateTime daterange= DateTime.nowDataRow[] foundrows = shifttable.Select("EMPLOYEEID ='" + empid.ToString() + "' and STARTDATE<='" + daterange + "' and ENDDATE>='" + daterange + "'");in this case ,the value of daterange is 2017-11-23 8:06:34 nm. that is why my code generate error. so I should parametrize my code. any help pleaseWhat I have tried:DateTime daterange= DateTime.nowDataRow[] foundrows = shifttable.Select("EMPLOYEEID ='" + empid.ToString() + "' and STARTDATE<='" + daterange + "' and ENDDATE>='" + daterange + "'");推荐答案 这篇关于如何将datetime值作为参数传递以从数据表中选择行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-28 18:18