This is a newbie question. I am creating a simple one-table Movie tracking program. I have dragged a db table onto the simple form creating a dataGridView. I am using a List box and some Text boxes to enter new data. For the life of me, I cannot get the data saved to the database table. The tableAdapter.Fill() process works fine to fill the dataGrid when I start the program, so the db works and the connection is good for data I have manually inserted into the table. However, using the dataGrid or the textboxes will not work to update the database table with new rows.

I have even combined everything into one step:

private void btnSave_Click(object sender, EventArgs e)
        {
            MoviesDataSet.MoviesRow newMovieRow;
            newMovieRow = moviesDataSet1.Movies.NewMoviesRow();
            newMovieRow.ID = this.moviesBindingSource.Count + 1;
            newMovieRow.Title = txtTitle.Text;
            newMovieRow.Actors = txtActors.Text;
            newMovieRow.Director = txtDirector.Text;
            newMovieRow.Description = txtDescription.Text;
            newMovieRow.Image = txtImage.Text;
            this.moviesDataSet1.Movies.Rows.Add(newMovieRow);
            this.moviesTableAdapter.Insert(newMovieRow.ID, newMovieRow.Title,   newMovieRow.Actors, newMovieRow.Director, newMovieRow.Description, newMovieRow.Image);
            this.moviesBindingSource.EndEdit();
            int rowsUpdated = this.moviesTableAdapter.Update(this.moviesDataSet1.Movies);
            MessageBox.Show(rowsUpdated.ToString() + ((rowsUpdated==1) ? " row" : " rows") + " updated.");
        }

The process runs and I get a number of rowUpdated that corresponds to the number of rows I try to save, but the db remains unchanged. I have manipulated this code a hundred ways. What am I doing wrong?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.