473,698 Members | 2,439 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Updating db from relational view - laborious or what?

Scenario:
I select data from a SQL Server View which links 3 tables, into a
single dataset table. I update some of those fields on a web form.
When I want to update the db, clearly I can't update via a View -
makes perfect sense.

But because I used a View, I can't use the CommandBuilder. I have to
specify my own Commands which will in some cases be huge and complex.
This seems crazy - what if I change the db structure? And because I
used a view, I've got no Primary Keys on my tables so I can't do
things like: DataRow myDataRow1 =
myDataSet.Table s["Customers"].Rows.Find("ALF KI");

It would clearly be simpler if I selected single tables using a Stored
Proc or a Select statement and then built the relationships manually,
but again, that sucks - what if I make changes to the db structure?
The same goes for the DataRow example above: I can specify on the
DataAdapter which column is the Primary Key but I don't want to be
coding db table metadata into my app.

Clearly, selecting and updating relational data is obviously a common
requirement, but ADO.NET makes the whole process incredibly laborious
and painful. And it ties the code directly to the structure of the db
which just has to be wrong.

Or I'm missing something. How are you guys handling the problem?
Nov 17 '05 #1
3 1307
Without knowing more about your database design, and the nature of the view,
it's hard to say much. Some views can be updatable.

When you say "I've got no Primary Keys on my tables", that's a little
worrying.

I tend to have a DataAccess class which works with SQL stored procedures,
and returns DataSets to it's callers. In some cases I'll have a class which
takes that DataSet, and exposes it in a more UI-friendly way by defining
properties to provide access to the records and fields of the DataSet.

At some level, your app will need to have some awareness of the database
structure. If only to access the data values by their column names in the
DataSet. If you were to change your underlying data structure, you could
still return a DataSet with the previous naming scheme. One way to make
this more explicit, is to avoid "select * ..." style queries. Always define
the fields that you want to be returned explicitly. That way, if you add
some columns to a table, any existing queries will be unaffected.

If you expect to change your database structure so drastically that the
relationships between your tables will be different, you ought to expect to
have to modify at least one aspect of the code that uses it.
Nov 17 '05 #2
William, I think we mostly agree. When I say "I've got no PKs on my
tables" I mean that, although the tables do have PKs (of course), when
they're returned to a DS via a View, it seems that ADO.Net can't
figure out which are the PK columns. So I have to define them myself
in the DS. Which is ridiculous.

As far as the CommandBuilder commands to update the DB are concerned,
as far as I understand it, I need to define the name, type, size etc
of every column I want to update. So it's not a question of only major
updates to the DB breaking the app, any minor - and let's face it,
pretty common - updates such as changing the length of the field will
do it as well.

Actually, I think I'm struggling toward understanding something a lot
more fundamental - it may be easier, from the point of view of
relationally updating a DB, to select individual tables and then
rebuild the relationships using a DataRelation (see
http://www.microsoft.com/mspress/boo...chap/5354i.asp - final para
in answer to the 2nd question).

My point in all of this is that the DAL is going to be tightly bound
to the DB. Even small changes will break the app. What happened to
abstraction and encapsulation? And what happened to RAD? This is all
SO laborious!
Nov 17 '05 #3
I've since found this article, which confirms my suspicions -
CommandBuilder sucks, Official.

http://msdn.microsoft.com/library/de...andbuilder.asp

I've never seen this sort of info anywhere else. Why on earth don't MS
just tell us that it can't handle Relational Views, Joins etc. Ok,
stupid question ...

I also found this, which was very helpful in understanding the
concepts. And I've ordered the book!

http://www.microsoft.com/mspress/boo...pchap/5354.asp

Hope this helps other poor sods trying to come to terms with this
mangled mess.
Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

34
7091
by: yensao | last post by:
Hi, I have a hard time to understand difference and similarities between Relational database model and the Object-Oriented model. Can somebody help me with this? Thank you in advance. Yensao
18
2750
by: comcast | last post by:
Hello all, I am developing an interface system for an application I was written. This interface will connect to other system to share information. I would like to use xml and xsl to generically describe each interface. The trouble I am having is that it seem that if you export in xml by table then it is impossible to combine the xml tables files back together in a hierarchical fashion. I can do it programmatically but I would like to...
0
1269
by: Olivier Jullian | last post by:
Hi, I'm new to .NET and am trying to take advantage of the object structure while accessing relational databases. I started a small project for managing "projects". Here is a description of my data structure : A project would be made of tasks, and each task can contain sub-tasks, so I would have something like
7
2289
by: Foxster | last post by:
in access i have two tables (tblplayer, tblpoints) in tblplayer i have field totalpoint (number) in tlbpoints i have field pointgame (number) the two files are related via idplayer now i made a query "qrybegan" and in that query i calculate a field sumpointgame which is the sum of all the field pointgame (option sum in the query) i have put in the query also the field totalpoint from the tblplayer now i want to put the sumpointgame in...
1
2188
by: Tim Fierro | last post by:
Hello, I have had many years using flat file databases (File Express from way back) but am now at a company where a relational database is needed and would carry us into the future. Since I know some basics on databases, have VB Pro programming experience over the years, and I know most of what we need to carry as far as data; I have decided to create a database for our needs instead of finding an off the shelf program that may not be...
6
3146
by: Mike Wilson | last post by:
Dear Group, I have a heirarchical set of database tables, say - "order" and "order_type" and want to display a series of orders in a grid control, and in place of the order_type foreign key identifier, I would like a dropdown combo box (lookup from the "order_type" table) to change the type of the order. I also need an update command button, a delete row button and also an insert new row button. I'm sure this is a very common design...
7
1659
by: Pradeep | last post by:
Hello, I need to take a set of input tables and create an XML output file. The format of the XML output must be user-definable and must be intuitive enough for non-techies to use. input table(s) + SomeSchemaDefinition ==XML file I have seen examples of XML file generation with fixed scope. For example, if input table (called customer) is as follows:
15
2490
by: slinky | last post by:
Thanks in advance fo rany help... I have an XML data file (well- formed) that I need to place into my website's app_data folder. I would like to have an .aspx form on my site that simply has two textboxes (corresponding to two XML fields in my file), and a "submit" button that will update the file. Any clues as to the code to use? I'm most familiar with the DataAdapter/DataSet model and using SQLserver files and having an INSERT INTO...
24
2087
by: sonos | last post by:
Hi, I am working on a program to archive data to disk. At what point is it best to use a relational database like MySQL as the backend instead of a C program alone? Thanks to any and all replies.
0
8683
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9031
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8904
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8876
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6531
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5867
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4624
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.