954,198 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

i cant save data on an access database

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.
Fruce

fruce
Newbie Poster
3 posts since Feb 2007
Reputation Points: 10
Solved Threads: 0
 

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

kapil.goyal
Light Poster
47 posts since Jan 2007
Reputation Points: 10
Solved Threads: 0
 
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

fruce
Newbie Poster
3 posts since Feb 2007
Reputation Points: 10
Solved Threads: 0
 

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");
            else
            {
                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;
                try
                {
                    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;
                    mamaDataSet.Pacient.Rows.Add(pr);
                    //daProducts.Update(dsStore1, "Products");
                    MessageBox.Show(maxId.ToString());
                    pacientTableAdapter.Update(mamaDataSet);
                }
            }
        }

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

dustman
Newbie Poster
4 posts since Mar 2007
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You