Good day, I am learning C# and someone has given me a certain software to write for him. I have been trying to add a new record to the Access Database that has already been connected to the Visual C# Application (Using Visual C# 2005) , using the DataSource and the DataAdapter objects, though i am able to add a new record to the program, it doesn,t save when i click on the save icon on visual C#.
Can anyone give me some hints and directions as how to solve the above mentioned problem, thanks.

10 Years
Discussion Span
Last Post by dustman

i hav to look into ur code wat exactly it is doing .so post the prob along with the code

there is no code. I have a database in microsoft access. i am working on visual C# 2005. i created a new windows application and then add the database from access on the form. when i tried to input some values onto the database and click the save icon, i realised it didnt save after i run the application again. i dont know what to do


hello....i have the same problem...the button for the Save buttons looks like this:

private void button1_Click(object sender, EventArgs e)
            if (name.Text == "" || surname.Text == "" || age.Text == null || entryDate == null)
                MessageBox.Show("Please enter all the data before pressing Add");
                mamaDataSet.PacientRow pr;
                int maxId;

                maxId = -1;
                foreach (mamaDataSet.PacientRow r in mamaDataSet.Pacient.Rows)
                    if (r.PacientId > maxId) maxId = r.PacientId;
                maxId = maxId + 1;
                pr = (mamaDataSet.PacientRow)mamaDataSet.Pacient.NewRow();
                pr.PacientId = maxId;
                pr.Name = name.Text;
                pr.Surname = surname.Text;
                bool b=false;
                    pr.Age = int.Parse(age.Text);
                catch (Exception es)
                    MessageBox.Show("Invalid age, please insert a number");
                    b = true;
                if (b != true)
                    DateTime startD = entryDate.SelectionStart;
                    pr.EntryDate = startD;
                    //daProducts.Update(dsStore1, "Products");

There at pacientTableAdapter.Update(mamaDataSet);, I tried with pacientTableAdapter.Insert(the_required_fields); but that didn't work either :(

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.