Click here to Skip to main content
16,016,759 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:

SQL
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 



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
Posted
Updated 9-Jun-13 1:02am
v2
Comments
Sunasara Imdadhusen 6-Jun-13 8:15am    
Have you written anything for the same?
nina4ever 10-Jun-13 15:49pm    
i am sorry, i did not get your question. what do you mean?

1 solution

For select query, you can try this:
SQL
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
 
Share this answer
 
v2
Comments
nina4ever 9-Jun-13 6:48am    
thank you Piyush. I would have written my query using JOIN as you have suggested, but TableAdapter would not generate (insert,update...) statements automatically... that's why i am trying to avoid joins
Piyush Dixit 10-Jun-13 6:21am    
In that case you can create a view in database for the above select statement and then query it.
nina4ever 10-Jun-13 15:52pm    
Would that allow TableAdapter to generate correct Update statements? How could it know which table to update since it sees a "view"?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900