要将数据从Datatable获取到Datarow中,请选择 [英] To get data into a Datarow from Datatable.select

查看:111
本文介绍了要将数据从Datatable获取到Datarow中,请选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI,

我想在vb.net代码中的quey下面使用

查询:



i want to use below quey in the vb.net code

query:

select count(*)As count,TLA_ITEM_NUMBER, MODEL_NUMBER from ace_cfg_blackbox where  CFG_ORDER_ID =''9052'' and  CFG_PSI_ID IN (''17208'') AND ENCLOSURE_ID > 1 AND SYSTEM_ID = 1 Group by TLA_ITEM_NUMBER, MODEL_NUMBER--And rownum <=1




Vb.Net代码




Vb.Net Code

m_blackBoxTable.Select("count(" + "*)As Count" + ", TLA_ITEM_NUMBER, MODEL_NUMBER " + "CFG_ORDER_ID =" + orderRow.Item("CFG_ORDER_ID").ToString + " AND CFG_PSI_ID IN (" + lstrReleasedPsi.ToString + ") AND ENCLOSURE_ID > 1 AND SYSTEM_ID = " + systemRow.Item("SYSTEM_ID").ToString + "Group by TLA_ITEM_NUMBER, MODEL_NUMBER")



但是它给出了运行时异常,如下所示



but its giving runtime exception as below

Run-time exception thrown : System.Data.SyntaxErrorException - Syntax error in aggregate argument: Expecting a single column argument with possible ''Child'' qualifier.



请帮助我.

如果以上代码中有语法错误,请告诉我.

在此先感谢.
subhash G.



pls help me out from this.

if there is any syntax error in the above code,pls let me know.

Thanks in Advance.
subhash G.

推荐答案

您不能在过滤器字符串中写入整个sql语句.

dataTable.Select(string filterexpression)的语法

filterexpression将仅包含where子句中的部分
它也可以包含一个排序顺序作为第二个参数.


http://msdn.microsoft.com/en-us/library/det4aw50.aspx [ ^ ]


您正在尝试使用LINQ
You cannot write entire sql statment in filter string.

syntax for dataTable.Select(string filterexpression)

filterexpression will containt only the part on where clause
It can also containt a sort order as second parameter.


http://msdn.microsoft.com/en-us/library/det4aw50.aspx[^]


What you are trying can be achieved using LINQ


这篇关于要将数据从Datatable获取到Datarow中,请选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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