在选定的数据源上找不到名称为“"的字段或属性 [英] A field or property with the name '' was not found on the selected data source

查看:143
本文介绍了在选定的数据源上找不到名称为“"的字段或属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在所选数据源上找不到名称为''的字段或属性,请为我提供解决方案

thx in Advanced

A field or property with the name '''' was not found on the selected data source please suggest me a solution

thx in advanced

推荐答案

实际上,数据库结果集中不存在您所选择的列.
例如:
Actually the selected column in your is not exists in database resultset.
For example:
SELECT EmpID, EmpName FROM Employee


如果您在程序中调用任何无效的列(如below0,则将显示该错误.可能是拼写错误,或者您可能在查询中使用别名(例如,SELECT ID AS EmpID, EmpName FROM Employee).

错误的


If you call any invalid column in your program(like below0 then it''ll show that error. May be typo or you might used alias in your query(Ex. SELECT ID AS EmpID, EmpName FROM Employee).

Wrong one

//-----------------------------
string strID = dr["ID"].Tostring();
//-----------------------------


对的


Right one

//-----------------------------
string strID = dr["EmpID"].Tostring();
//-----------------------------


这篇关于在选定的数据源上找不到名称为“"的字段或属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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