locked
tableadapter problems RRS feed

  • Question

  • Hi there,

    i have some dummie code

    Public Class Form1

    Private Sub Table_1BindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Table_1BindingNavigatorSaveItem.Click

    Me.Validate()

    Me.Table_1BindingSource.EndEdit()

    Me.TableAdapterManager.UpdateAll(Me.CrapDataSet)

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    'TODO: This line of code loads data into the 'CrapDataSet.Table_1' table. You can move, or remove it, as needed.

    Me.Table_1TableAdapter1.Fill(Me.CrapDataSet.Table_1)

    End Sub

    End Class

    -----------------------

    But i am getting an error

    "Update requires a valid UpdateCommand when passed DataRow collection with modified rows."

    Im new to this stuff so i cant find a post that really explains what i need to do.
    I can read from the database, but not update.  I read somewhere that there are
    missing necessary SQL statements for the Delete and Update commands, but i cant find where to enter them in nore what needs to be entered in

    Any help would be great

    • Moved by VMazur Friday, March 6, 2009 10:51 AM Move to correct forum (Moved from ADO.NET Data Providers to Windows Forms Data Controls and Databinding)
    Friday, March 6, 2009 6:26 AM

Answers

  • Hi Andy,

    It seems that the UpdateCommand of the Table_1TableAdapter is not set. Double click the DataSet in the Solution Explorer to open the DataSet. Select the Table_1TableAdapter in the DataSet and switch to Properties window. Navigate to the UpdateCommand entry to see if the value is none.

    We needn't configure the SelectCommand, InsertCommand, DeleteCommand and UpateCommand manually, instead we generally use the TableAdapter Configuration wizard to do this. Right click on the Table_1TableAdapter and choose "configure" command. In the "Choose Methods to Generate" window, select the option "Fill a DataTable" at least and follow the instructions to finish the configuration.

    Hope this helps.
    If you have any question, please feel free to let me know.

    Sincerely,
    Linda Liu

    • Marked as answer by Linda Liu Thursday, March 12, 2009 5:54 AM
    Tuesday, March 10, 2009 4:33 AM