View Update

FrancoBasal

New member
Joined
Jun 21, 2007
Messages
1
Programming Experience
5-10
Hello , here is my problem , I do it a binding between a view and a tableadapter in dataset with the CRUD form. I can see the records very well. but i cant update it because i cant see the "update metods" ( Update , New , delete )
I Know that this happens when the view includes many tables, without allowing to update. Is there any way to solve this ??? without write the updates?

sorry by my english.

Best regards.
 
Typically views can only be updated if the uniqueness of all the keys used is preverved. Your RDBMS may be able to isolate parts of the view for update, but that is all

For example, you have a Person table, and their salutation (Mr, Mrs, Miss ..) is an ID integer, decoded by table DecodeSalutation

Person: SalID, FirstName, LastName
1, John, Smith
2, Jane, Smith
2, Sarah, Smith

DecodeSalutation: SalID, SalText


As a query:

CREATE VIEW TmpVw AS
SELECT SalText, FirstName, LastName FROM Person NATURAL INNER JOIN DecodeSalutation


Only FirstName and LastName will be updatable. What if you said:

UPDATE TmpVw SET SalText = FirstName


You have Sarah and Jane, both with SalID 2, how can you set the SalText for ID 2, to both Jane and Sarah at the same time? No can do..


Dont try to update views. Instead, write a query or queries or stored procedure that updates the individual tables, or.. only update the key preserved parts of the view (in this case, FirstName and LastName)
 
Back
Top