C#2.0 - 将查询结果(JOIN)绑定到DataGridView [英] C# 2.0 - Binding Query Results (JOIN) to DataGridView
问题描述
问候,
我有两个SQL表,每个表在DataSet中都有一个强类型的DataTable。我想创建一个DataGridView,它显示这两个表上的JOIN操作的结果,更重要的是,它可以绑定到这个查询结果 - 这样如果其中一个表更新,底层DataTable(由JOIN查询生成并绑定到我的DataGridView)也将自动更新。
I have two SQL tables, each of which has a strongly-typed DataTable within a DataSet. I would like to create a DataGridView that shows the results of a JOIN operation on these two tables, and more importantly, that can be bound to this query result -- so that if one of the tables updates, the underlying DataTable (that is generated by the JOIN query and bound to my DataGridView) will also update automatically.
这是可能的,还是我必须监视两个表中任何一个表的更改,然后每次都对它们执行查询?在TableAdapter向导中,我创建了一个查询,但是我只有两个选项是创建一个(a)将"填充"的函数。我传入的DataTable或(b)根据查询结果返回一个DataTable。这两个选项都不允许我将DataGridView的绑定源设置为静态表,然后可以随时更新任一基础表。
Is this possible, or will I have to monitor for changes to either of the two tables and then perform my query on them each time? In the TableAdapter wizard, I created a query, however my only two options were to create a function that (a) would "Fill" a DataTable I pass in or (b) return a DataTable based on the query results. Neither of these options will allow me to set a DataGridView's binding source to a static table that can then update any time either of the underlying tables changes.
提前感谢,
Rick
推荐答案
这可能对您有所帮助
This might help you
http://support.microsoft.com/kb/326080/en-us
这篇关于C#2.0 - 将查询结果(JOIN)绑定到DataGridView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!