从数据库表中检索值时出错. [英] Error-while retrieving value from DB Table.
本文介绍了从数据库表中检索值时出错.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的C#Windows应用程序中,我正在尝试从数据库表中检索一个整数值.
检索时,值会加载到数据集中.但是在将该值分配给诸如
的某些变量时
Hi, in my C# Windows Application Am trying to retrieve a interger value from the database table.
While retrieving ,value is loaded in the dataset. but while assigning that value to some variable like
string s = ds.Tables[0].Rows[0]["Pid"].ToString();
它给出错误,因为"列"Pid"不属于表Table."
给我一个解决方案.
谢谢.
it give an error as "Column ''Pid'' does not belong to table Table."
Give me a solution for this.
thank u.
推荐答案
列" Pid不属于表Table."
这是因为您假设行中有一个名为"Pid"的列,因此您尝试从检索到的表行中访问一个值,在这里:
"Column ''Pid'' does not belong to table Table."
This is because you are trying to access a value from retrieved table row assuming you have a column named ''Pid'' in the row, here:
ds.Tables[0].Rows[0]["Pid"].ToString();
检查您的查询并确保您返回了名为"Pid"的列.
Check your query and make sure you have a column named ''Pid'' returned.
我认为这是因为您的表不包含列名"Pid",因此请检查表'的列名称.
I think this is because your Table does not contain a column name "Pid" so check your table''s columns names.
这篇关于从数据库表中检索值时出错.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文