Link to home
Start Free TrialLog in
Avatar of Abdullah Abdulkarim
Abdullah AbdulkarimFlag for United States of America

asked on

Access Database connected to App C#

I got problem with  visual studio C# connection to Access  database, when I tried to insert data in the app, I see it entered but when I close the app and check the database it self ,  It  is showing  nothing in the database . I do not know why it is not saved in the database since there is connection and I checked it gave me success .

code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Haspital_HadithahEmplyeeSys1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void employeeDataBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            this.Validate();
            this.employeeDataBindingSource.EndEdit();
            this.tableAdapterManager.UpdateAll(this.healthCareDataDataSet);

        }

        private void Form1_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'healthCareDataDataSet.EmployeeData' table. You can move, or remove it, as needed.
            this.employeeDataTableAdapter.Fill(this.healthCareDataDataSet.EmployeeData);

        }

        private void employeeDataBindingSource_AddingNew(object sender, AddingNewEventArgs e)
        {
            this.employeeDataTableAdapter.Update(this.healthCareDataDataSet);
        }
    }
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of John Tsioumpris
John Tsioumpris
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Abdullah Abdulkarim

ASKER

I did it but it is  still  same-thing not changing   , on the app it showing save but when I close it already deleted.

private void employeeDataBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            this.Validate();
            this.employeeDataBindingSource.EndEdit();
            this.tableAdapterManager.UpdateAll(this.healthCareDataDataSet);
            DataSet changedRecords = healthCareDataDataSet.GetChanges();
            DataSet changedRecords1 = healthCareDataDataSet.GetChanges();

        }

        private void Form1_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'healthCareDataDataSet.EmployeeData' table. You can move, or remove it, as needed.
            this.employeeDataTableAdapter.Fill(this.healthCareDataDataSet.EmployeeData);
            
        }
        private void employeeDataBindingSource_AddingNew(object sender, AddingNewEventArgs e)
        {
            this.employeeDataTableAdapter.Update(this.healthCareDataDataSet);
        }
    }
}

Open in new window

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Can you post the connection string please and also post the actual database file location you are checking you may be looking at the wrong database file.
Okay i will send it you but i need some time because i am out side of work.
Thank you for your respond quick.
Not a problem.  👍
@Abdullah Abdulkarim, please update this question. Thank you.
Should have corrected the issue.