|
-
November 4th, 2008, 01:15 PM
#1
Multiple tables
Hello!
I'm new to this ADO thing so I have some questions. I'm using Visual Studio 2005 (.NET 2.0) and Oracle 10.
I understand how the OracleDataAdapter.Fill and .Update works for single tables (SELECT * FROM one_table). But how does it work if I do a more complex commandtext?
Like:
SELECT e.FirstName, o.ShipCity FROM Employees e, Orders o WHERE e.EmployeeID = o.EmployeeID ORDER BY e.FirstName
If I do a Fill() on that one, I get a result with FirstName from Employee and ShipCity from Orders. Like a charm.
But if I do an Update(), how would the code know that changes to FirstName goes into Employee and changes to ShipCity goes into Orders, and at the same time check so it's the right EmployeeID?
So, in other words what I want to achieve is:
I want to select a bunch of information from different tables. Show this to the user in a grid where the user can alter this information and then save the changes that the user have made.
-
November 4th, 2008, 01:31 PM
#2
Re: Multiple tables
You have to split it up.
Typically there are two approaches (and the best solutions use BOTH)
1) ALWAYS use stored procedures. This provides additional security and encapsulation.
2) KEEP the data in separate tables (use a DataSet and DataRelation). If you don't "Combine" then you don't need to "Split.
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions 
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
-
November 6th, 2008, 08:51 AM
#3
Re: Multiple tables
Thanks TheCPUWizard for your answer.
For starters so do I only try approach #2 at the moment.
In my DataSet, I have now created two tables and a relation between them.
Further more so do I now use two DataAdapters, one to fill the Employees table and the other one to fill the Orders table in my DataSet. Seems to work like a charm.
But how do I do now to get the information out from my DataSet into a grid so it looks like I have done this query?
Code:
SELECT e.FirstName, o.ShipCity FROM Employees e, Orders o WHERE e.EmployeeID = o.EmployeeID ORDER BY e.FirstName
EDIT:
I can also mention that I have tried with a DataGrid, but I got "+"-signs that I had to press to view the Order-data for just that Employee.
What I want to achieve is all columns visible just like if I have done the query above, and still be able to edit values and save stuff where it belong.
Last edited by Ragowit; November 6th, 2008 at 11:47 AM.
-
November 11th, 2008, 06:16 AM
#4
Re: Multiple tables
You are looking for exactly i wrote an Article About.
See this , the Difference its onyl that am using SQL
http://www.codeproject.com/KB/cs/N-Tier22.aspx
Hope it helps
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|