如何解决错误 - 无法评估表达式。操作不受支持。未知错误:0x80070057 [英] How to solve error - unable to evaluate the expression. Operation not supported. Unknown error: 0x80070057

查看:250
本文介绍了如何解决错误 - 无法评估表达式。操作不受支持。未知错误:0x80070057的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

DataTable dttable = new DataTable();
dttable.Columns.Add("billno", typeof(String));
dttable.Columns.Add("date", typeof(DateTime));
dttable.Columns.Add("time", typeof(String));
dttable.Columns.Add("covers", typeof(Decimal));
dttable.Columns.Add("trcode", typeof(String));
dttable.Columns.Add("scode", typeof(String));
dttable.Columns.Add("gname", typeof(String));
dttable.Columns.Add("total", typeof(Decimal));
dttable.Columns.Add("login", typeof(String));
dttable.Columns.Add("resno", typeof(String));
dttable.Columns.Add("custcode", typeof(String));
dttable.Columns.Add("resnum", typeof(Int32));
dttable.Columns.Add("sname", typeof(String));
dttable.Columns.Add("name", typeof(String));
dttable.Columns.Add("qty", typeof(Decimal));
dttable.Columns.Add("rate", typeof(Decimal));

var rows = from mobjbmast in Context.bmasts.AsEnumerable()
           join mobjbtran in Context.btrans
           on mobjbmast.billno equals mobjbtran.billno
           join mobjwaiter in Context.waiters
           on mobjbmast.scode equals mobjwaiter.code
           where mobjbmast.billno == mbillno
           select dttable.LoadDataRow(new object[]
           {
                 mobjbmast.billno,
                 mobjbmast.date,
                 mobjbmast.time,
                 mobjbmast.covers,
                 mobjbmast.trcode,
                 mobjbmast.scode,
                 mobjbmast.gname,
                 mobjbmast.total,
                 mobjbmast.login,
                 mobjbmast.resno,
                 mobjbmast.custcode,
                 mobjbmast.resnum,
                 mobjwaiter.name,
                 mobjbtran.name,
                 mobjbtran.qty,
                 mobjbtran.rate
           }, false);





上面的代码在数据表中没有返回任何行并调试'rows'变量显示错误:



无法评估表达式。操作不受支持。未知错误:0x80070057



请注意。在此先感谢。



我尝试过:





The above code returns no rows in the datatable and on debugging the 'rows' variable show the error :

Unable to evaluate the expression. Operation not supported. Unknown error: 0x80070057

Please suggest. Thanks in advance.

What I have tried:

var rows = from mobjbmast in Context.bmasts.AsEnumerable()
           join mobjbtran in Context.btrans.AsEnumerable()
           on mobjbmast.billno equals mobjbtran.billno
           join mobjwaiter in Context.waiters.AsEnumerable()
           on mobjbmast.scode equals mobjwaiter.code
           where mobjbmast.billno == mbillno
           select new { billno = mobjbmast.billno, date = mobjbmast.date, time = mobjbmast.time, trcode = mobjbmast.trcode };





即使这样也会出现同样的错误。如果我将AsEnumerable()更改为ToList(),那么我得到Enumeration没有结果。



Even this gives the same error. If I change the AsEnumerable() to ToList() then I get Enumeration yielded no results.

推荐答案

你可以尝试



You may try

IEnumerable<DataRow> _query = ...... Your expression

DataTable boundTable = _query.CopyToDataTable<DataRow>();


此代码适合我。从其中一个网站获得此解决方案。将此作为答案发布,以便它可以帮助其他人。下面的代码用于在某些条件下查询连接表中的数据,并从结果对象数组中加载Datatable(具有已知列)。



This code works for me. Got this solution from one of the websites. Posting this as answer so it can help some body else. The below code is for querying data from joined tables on some condition and loading a Datatable (with known columns) from the resultant object array.

DataTable dttable = new DataTable();

dttable.Columns.Add("billno", typeof(String));
dttable.Columns.Add("date", typeof(DateTime));
dttable.Columns.Add("time", typeof(String));
dttable.Columns.Add("covers", typeof(Decimal));
dttable.Columns.Add("trcode", typeof(String));
dttable.Columns.Add("scode", typeof(String));
dttable.Columns.Add("gname", typeof(String));
dttable.Columns.Add("total", typeof(Decimal));
dttable.Columns.Add("login", typeof(String));
dttable.Columns.Add("resno", typeof(String));
dttable.Columns.Add("custcode", typeof(String));
dttable.Columns.Add("resnum", typeof(Int32));
dttable.Columns.Add("sname", typeof(String));
dttable.Columns.Add("name", typeof(String));
dttable.Columns.Add("qty", typeof(Decimal));
dttable.Columns.Add("rate", typeof(Decimal));

var rows = from mobjbmast in Context.bmasts.AsEnumerable()
           join mobjbtran in Context.btrans
           on mobjbmast.billno equals mobjbtran.billno
           join mobjwaiter in Context.waiters
           on mobjbmast.scode equals mobjwaiter.code
           where mobjbmast.billno == mbillno
           let billarray = new object[]
           {
                mobjbmast.billno,
                mobjbmast.date,
                mobjbmast.time,
                mobjbmast.covers,
                mobjbmast.trcode,
                mobjbmast.scode,
                mobjbmast.gname,
                mobjbmast.total,
                mobjbmast.login,
                mobjbmast.resno,
                mobjbmast.custcode,
                mobjbmast.resnum,
                mobjwaiter.name,
                mobjbtran.name,
                mobjbtran.qty,
                mobjbtran.rate
            }
            select billarray;
            foreach (var array in rows)
            {
                dttable.Rows.Add(array);
            }


这篇关于如何解决错误 - 无法评估表达式。操作不受支持。未知错误:0x80070057的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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