Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Parent/Child/Update
Message
De
10/05/2006 18:51:28
Jason Mesches
Ocean Systems Engineering Corporation
Carlsbad, Californie, États-Unis
 
 
À
10/05/2006 17:25:56
Jeff Corder
Ambit Technologies, LLC
Missouri, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Divers
Thread ID:
01120811
Message ID:
01120836
Vues:
22
As you found out, by default, the commandbuilder will try to use the same statement to save as the one you used to retrieve data. To get around this, use your business object's UpdateSelectStatement and set it like this:
this.UpdateSelectStatement = "SELECT * FROM " + this.PhysicalDbcObjectName + 
	" WHERE " + this.PrimaryKey + " < 0";
Now the command builder will only "care" about your primary table and none of the ones in the JOIN conditions. Of course, this assumes your primary key is an integer that doesn't allow values less than 0. The reason you want to include the WHERE statement is that .NET will perform a round trip and actually run this query to get schema from which to derive an UPDATE statement. For obvious reasons, you don't want it to take any longer than absolutely necessary.

Hope that helps,
---J

>I have a table with a foreign key in my form (no problem yet). I have a generic search form which allows the user to select the row(s) they want to edit. Since there is a foreign key, I want to display the data, not the foreign key (I used a JOIN) and allow the user to make a filter selection. I am currently passing the table to the generic search form, making the selection and returning it. The problem is that when I attempt to update the data, the CommandBuilder chokes because I have use a JOIN to put the data together.
>
>I am trying to figure out how to handle this problem without losing the functionality I have considered:
>
>1) Set the foreign fields to ReadOnly, but the CommandBuilder wasn't paying attention and only noticed the JOIN statement, not that it wasn't supposed to save any of those columns.
>
>2) Overload the CreateUpdateCommand() to just update the parent table (thus taking the CommandBuilder out of the loop). I can't find where to overload the method - or some other way to provide the UpdateQuery.
>
>3) Adding the business and child objects to the search form, but since the objects keep changing, I'm not sure about how to create them generically. Also if the user selects a child comparison as a filter (i.e. "City LIKE 'D%'") that will not easily translate into a foreign key.
>
>I appreciate any suggestions,
>Jeff Corder
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform