SQL Data Adapter Configuration Wizard not making UPDATE command
I am trying to make a SQLDataAdapter connecting to a VIEW (not a table), which was constructed from several tables. All tables related to this VIEW have primary key columns which were linked together through relationship in diagram.
In Visual Studio, the Data Adapter Configuration Wizard went through fine making SELECT and INSERT command but failed to make UPDATE and DELETE command. I chose 'Create new stored procedure' option in the middle of wizard. The message was "Could not determine which columns uniquely identify the rows for 'MyView'." But actually there was a column uniquely identify the rows.
At first, it seemed understandable because a VIEW is a simply dynamically binding SQL SELECT statement so that it does not include a primary key like a TABLE. But considering that this VIEW is updatable from direct editing environment like MS Access ADP page or SQL Enterprise Manager, it SHOULD be able to make UPDATE command too for a VIEW. And 'MyView' satisfies all conditions for being an 'Updatable View' according to SQL online manual.
I really would like to know that if this is just a design feature or I am doing something wrong. I think it is important point because if a VIEW can be treated exactly like a TABLE (Microsoft said that a VIEW is kind of a 'virtual TABLE') it can make big difference in coding.
What I am thinking is like this. You have lots of tables in SQL server. Then make a VIEW which links all the complex tables. Then in the program side, you can code a connection to this VIEW not to every TABLES. Later, when you need to change some schema of TABLES, you only need to change the VIEW and/or the stored procedure without touching already deployed application.
But if 'VS Data Adapter Configuration Wizard' cannot make UPDATE command for VIEWS then I can't allow users to edit the DataSet and UPDATE the database. Of course I know I can bind SQL commands manually but when there are so many complex named columns in many tables it is a pain in the neck.
Any better idea or comment?
Or can anybody suggest a "BEST PRACTICE" when you are designing a database and writing a client application at the same time?
Here I copy the SQL query of 'MyView' captured from QueryAnalyzer.
--
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
ALTER VIEW dbo.PartsFab
WITH SCHEMABINDING, VIEW_METADATA
AS
SELECT dbo.Parts.[Part Number], dbo.PartsFabInfo.Active, dbo.Parts.Type, dbo.Parts.Description AS [Part Name], dbo.PartsFabInfo.Material,
dbo.PartsImage.[Drawing File], dbo.PartsRemark.Remark, dbo.PartsFabInstruction.Instruction, dbo.PartsFabInfo.[Process 1],
dbo.PartsFabInfo.[Process 2], dbo.PartsFabInfo.[Process 3], dbo.PartsFabInfo.[Process 4], dbo.PartsFabInfo.[Process 5], dbo.PartsFabInfo.[Process 6],
dbo.PartsFabInfo.[Process 7], dbo.PartsFabInfo.[Process 8], dbo.PartsFabInfo.[Process 9], dbo.PartsFabInfo.[Process 10], dbo.Inventory.[Qty OnHand],
dbo.BlankSize.L1, dbo.BlankSize.W1, dbo.BlankSize.N1, dbo.Shiplist1.Quantity AS SR, dbo.Shiplist2.Quantity AS RB,
dbo.Shiplist3.Quantity AS EL, dbo.Shiplist4.Quantity AS MV, dbo.Shiplist5.Quantity AS RN
FROM dbo.Parts LEFT OUTER JOIN
dbo.PartsFabInfo ON dbo.Parts.[Part Number] = dbo.PartsFabInfo.[Part Number] LEFT OUTER JOIN
dbo.PartsFabInstruction ON dbo.Parts.[Part Number] = dbo.PartsFabInstruction.[Part Number] LEFT OUTER JOIN
dbo.PartsImage ON dbo.Parts.[Part Number] = dbo.PartsImage.[Part Number] LEFT OUTER JOIN
dbo.PartsRemark ON dbo.Parts.[Part Number] = dbo.PartsRemark.[Part Number] LEFT OUTER JOIN
dbo.Inventory ON dbo.Parts.[Part Number] = dbo.Inventory.[Part Number] LEFT OUTER JOIN
dbo.BlankSize ON dbo.Parts.[Part Number] = dbo.BlankSize.[Part Number] LEFT OUTER JOIN
dbo.Shiplist3 ON dbo.Parts.[Part Number] = dbo.Shiplist3.[Part Number] LEFT OUTER JOIN
dbo.Shiplist4 ON dbo.Parts.[Part Number] = dbo.Shiplist4.[Part Number] LEFT OUTER JOIN
dbo.Shiplist2 ON dbo.Parts.[Part Number] = dbo.Shiplist2.[Part Number] LEFT OUTER JOIN
dbo.Shiplist5 ON dbo.Parts.[Part Number] = dbo.Shiplist5.[Part Number] LEFT OUTER JOIN
dbo.Shiplist1 ON dbo.Parts.[Part Number] = dbo.Shiplist1.[Part Number]
WHERE (dbo.Parts.[Part Number] NOT LIKE '#%')
WITH CHECK OPTION
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

