Would some please look at my code. The line I\'m have issues with is this this.t
ID: 3875499 • Letter: W
Question
Would some please look at my code. The line I'm have issues with is this this.tableAdapterManager.UpdateAll(this.bookDataSet);
I cannot find out why it does not work. Everything else works but this one thing.
Thank you, GOD Bless
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Data.Entity;
using System.Data.Entity.Validation;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace DisplayTable
{
public partial class DisplayAuthorsTableApp : Form
{
public DisplayAuthorsTableApp()
{
InitializeComponent();
}
private void searchlabel_Click(object sender, EventArgs e)
{
}
private void AuthorDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void searchTextBox_TextChanged(object sender, EventArgs e)
{
}
private void searchButton_Click(object sender, EventArgs e)
{
var lastNameQuery = from author in dbcontext.Authors where author.LastName.StartsWith(searchTextBox.Text) orderby author.LastName, author.FirstName select author;
authorBindingSource.DataSource = lastNameQuery.ToList();
authorBindingSource.MoveFirst();
bindingNavigatorAddNewItem.Enabled = false;
bindingNavigatorDeleteItem.Enabled = false;
}
private void showAllButton_Click(object sender, EventArgs e)
{
bindingNavigatorAddNewItem.Enabled = false;
bindingNavigatorDeleteItem.Enabled = false;
RefreshAuthor();
}
private void AuthorDataGridView_CellContentClick_1(object sender, DataGridViewCellEventArgs e)
{
}
private void authorBindingNavigatorSaveItem_Click(object sender, EventArgs e)
{
this.Validate();
this.authorBindingSource.EndEdit();
//this.tableAdapterManager.UpdateAll(this.bookDataSet);
}
ClassLibrary.BooksEntities dbcontext = new ClassLibrary.BooksEntities();
private void DisplayAuthorsTable_Load (object sender, EventArgs e)
{
RefreshAuthor();
}
private void RefreshAuthor()
{
if(dbcontext != null)
{
dbcontext.Dispose();
}
dbcontext = new ClassLibrary.BooksEntities();
dbcontext.Authors.ToList();
authorBindingSource.DataSource = dbcontext.Authors.Local;
authorBindingSource.MoveFirst();
searchTextBox.Clear();
}
}
}
Explanation / Answer
Enclose the TableAdapter'sUpdate method in a try/catch block.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.