When I click on my save button I receive this message. But sound that everything it's right? Why this message? "
using System.Data.OleDb;
namespace LunaOffice
{
public partial class VisualRecursosHumanos : Form
{
OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\lunaoffice\lunaoffice\app_data\office.accdb;");
public VisualRecursosHumanos()
{
InitializeComponent();
}
OleDbConnection con;
DataSet ds1;
OleDbDataAdapter da;
int MaxRows = 0;
int inc = 0;
private void Save_Click(object sender, EventArgs e)
{
//////////////////////////
System.Data.OleDb.OleDbCommandBuilder cb;
cb = new System.Data.OleDb.OleDbCommandBuilder(da);
DataRow drow = ds1.Tables["funcionario"].NewRow();// The bug it's here
drow[0] = txtNomesCadastFunc.Text;
ds1.Tables["funcionario"].Rows.Add(drow);
MaxRows = MaxRows + 1;
inc = MaxRows - 1;
con.Open();
da.Update(ds1, "funcionario");
con.Close();
MessageBox.Show("Record / Entry Added");
}
private void VisualRecursosHumanos_Load(object sender, EventArgs e)
{
//con = new.OleDbConnection();
ds1 = new DataSet();
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:/lunaoffice/lunaoffice/app_data/office.accdb";
string sql = "SELECT * from funcionario";
da = new OleDbDataAdapter(sql, con);
con.Open();
da.Fill(ds1, "funcionario");
//NavigateRecords();
MaxRows = ds1.Tables["funcionario"].Rows.Count;
con.Close();
con.Dispose();
}
}