为什么我无法通过表名访问数据集中的表?
在我的 VB.Net 桌面应用程序中,我在多个位置访问表,以进行读取和更新。例如:
Dim tempCount As Integer = Glbl.GlobalDataSet.Tables("Profiles").Rows.Count
上面的方法不起作用。然而,以下情况确实如此:
Dim tempCount As Integer = Glbl.GlobalDataSet.Tables(4).Rows.Count
我很确定它在过去可以工作(我最近切换到 VS 2010 - 这可能与它有什么关系吗?)但它现在不工作。
如何使第一条语句起作用,以便可以通过表名而不是索引访问表?
In my VB.Net desktop application, I have several places where I am accessing a table, both for reading and for updating. For example:
Dim tempCount As Integer = Glbl.GlobalDataSet.Tables("Profiles").Rows.Count
The above does not work. However, the following does:
Dim tempCount As Integer = Glbl.GlobalDataSet.Tables(4).Rows.Count
I am pretty sure it was working in th past (I have recently switched to VS 2010 - could this have anything to do with it?) but it is not working now.
How can I make the first statement work, so can access tables by table name instead of by index?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它应该可以工作,请确保数据表的名称正确。使用属性窗口检查然后重建项目。
It should be working, make sure that the name of the DataTable is correct. Use the property window to check then rebuild the project.
确保将表名称分配给数据集中的表 4,如果没有在编写问题中的第一个代码部分之前更改表名称,
请尝试使用表名称获取表的计数,或者在填充数据库时您可以通过指定表名称来填充从数据库到数据集的值。
Make sure that the table name is assigned to the tables 4 in your dataset, if not before writing the first code part in your question change the table name like
after this try getting the count of the table using table name, or while filling the database values from database to the dataset you fill it by specifying the table name.