DataGridView,其中两个表中的列和行均按where条件过滤 [英] DataGridView with columns from two tables and rows filtered by a where condition
问题描述
亲爱的所有人,
我想使用DataGridView显示和更新特定表的数据.
我需要帮助来创建类型化的数据集作为BindingSource对象的数据源.
我的问题是:
1-并非我所有的列都来自一个表.一列( dept_name )应该由子查询从另一张表中检索,但不会被更新.
2- TableAdapter应该使用的Select语句具有一个( where条件),其中带有用户插入的参数,然后用正确的数据填充网格.
这是我的查询的简化版本:
Dear all,
I want to display and UPDATE the data of a certain table using DataGridView.
I need help to create a typed DataSet to be the DataSource for my BindingSource object.
My problem is :
1- Not all of my columns come from one table. One column (dept_name) should be retrieved from another table by a subquery, but It’s not gonna be updated.
2- Select statement that should be used by the TableAdapter has a (where condition) with parameters inserted by the user before populating the grid with correct data.
Here''s a simplified version of my query:
Select dept_id , SEQ ,time_stamp ,
(selec dept _name from Departments D where D.dept_id = H.dept_id)
From History H
Where seq = v_input_seq
注意:我不想在查询中使用JOIN,因为TableAdapter不会自动为我生成(插入,更新...)语句.
任何人都可以帮助我创建数据集和配置,而TableAdapter抛出WIZARD吗?
在此先感谢
Note: i don''t want to use JOIN in my query, because TableAdapter wouldn''t generate (insert, update...) statements automatically for me.
Can anyone help me with creating the DataSet and configuring and TableAdapter throw the WIZARD, please?
Thanks in advance
推荐答案
对于选择查询,您可以尝试以下操作:
For select query, you can try this:
Select H.dept_id , SEQ ,time_stamp , dept _name
From History H inner join Departments D on D.dept_id = H.dept_id
Where seq = v_input_seq
这篇关于DataGridView,其中两个表中的列和行均按where条件过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!