Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Another Newbie Question
Message
De
21/10/2008 08:20:22
 
 
À
21/10/2008 00:25:01
Information générale
Forum:
ASP.NET
Catégorie:
Bases de données
Versions des environnements
Environment:
VB 9.0
OS:
Vista
Network:
Windows 2008 Server
Database:
MS SQL Server
Divers
Thread ID:
01355730
Message ID:
01356023
Vues:
23
Bonnie


Thanks for your reply.

No, this is a single table update. This is a learning exercise and that's all this program does. I have a two field SQL table with an identity field and a character field and I want to be able to service that table.

I created a dataset, created a form, added the textboxes and added a bindingnavigator.

There is no other code. I just ran the form.

The tableadapters and tableadaptermanagers and a bindingsource appeared on their own after I installed the bindingnavigator and bound some SQL fields to my text boxes.

> suspect the problem is because you haven't defined the proper select/update/insert/delete commands when you defined your TableAdapters.

Yes, that was the problem. The wizard was supposed to have generated those commands and it didn't.

Google revealed that it's a common problem. Several mentioned that a common cause is the absence of a primary key in the project's schema for the table, so I designated the identity field as a primary key in the dataset designer and redid the wizard, to no avail. I tried making a brand new project with a primary key, still no luck.

Many people on Google gave up and used dbcommandbulder to create the commands. Others said that they always created the commands themselves in code.

After stumbling around with the dbcommandbuilder class, I gave up and wrote some code that added the update command to the dataadapter myself before running the update method, and that solved the problem.


>However, you can configure the INSERT, UPDATE and DELETE commands manually in the Properties window.

That would have been good, but I couldn't find a place to do it. I could only see a way to change the fill command, but not the others. How do I get that Properties window?

I'm wondering if the identity field is confusing the wizard.

Next, I plan to try a new project with the same table, but with no navigator and some bound text boxes, and my own Forward, Back and Save buttons.














>I haven't used TableAdapterManagers (or TableAdapters either, for that matter), but I suspect the problem is because you haven't defined the proper select/update/insert/delete commands when you defined your TableAdapters. I hope you are using multiple related tables in your DataSet, because the TableAdapterManager is used for hierarchical updates.

So, the docs say this about the TableAdapterManager:

The generated TableAdapterManager contains a property for each TableAdapter it manages. For example, a dataset with a Customers and Orders table is generated with a TableAdapterManager that contains CustomersTableAdapter and OrdersTableAdapter properties.

And say this about the TableAdapter:

The update functionality of a TableAdapter is dependent on how much information is available based on the main query provided in the TableAdapter Wizard. For example, TableAdapters that are configured to fetch values from multiple tables (JOINs), scalar values, views, or the results of aggregate functions are not initially created with the ability to send updates back to the underlying database. However, you can configure the INSERT, UPDATE and DELETE commands manually in the Properties window.

So, the question becomes ... how did you configure your TableAdapters? Is the data from relatively simply queries? If so, I'm guessing you missed a step somewhere in the wizard that generated these things perhaps. Not sure what else I can guess at without more information. =0(

~~Bonnie





>VS 2K8
>C#
>
>The program bombs with
>“Update requires a valid UpdateCommand when passed DataRow collection with modified rows.”
>
>when I excecute the system-generated code on the savve button of the navigation toolbar below:
>
>private void holderBindingNavigatorSaveItem_Click_1(object sender, EventArgs e)
> {
> this.Validate();
> this.holderBindingSource.EndEdit();
> this.tableAdapterManager.UpdateAll(this.portfolioDataSet);
>
>This is a two column table. One column is the identity field and the next is a name.
>
>I've configured in the dataset mgr ad nauseum.
>
>Any suggestions greatly appreciated
Anyone who does not go overboard- deserves to.
Malcolm Forbes, Sr.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform