944,022 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 8860
  • C# RSS
Feb 16th, 2007
-1

i cant save data on an access database

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
fruce is offline Offline
3 posts
since Feb 2007
Feb 16th, 2007
0

Re: i cant save data on an access database

i hav to look into ur code wat exactly it is doing .so post the prob along with the code
Reputation Points: 10
Solved Threads: 0
Light Poster
kapil.goyal is offline Offline
47 posts
since Jan 2007
Feb 16th, 2007
0

Re: i cant save data on an access database

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
fruce is offline Offline
3 posts
since Feb 2007
Sep 28th, 2007
0

Re: i cant save data on an access database

hello....i have the same problem...the button for the Save buttons looks like this:
C# Syntax (Toggle Plain Text)
  1. private void button1_Click(object sender, EventArgs e)
  2. {
  3. if (name.Text == "" || surname.Text == "" || age.Text == null || entryDate == null)
  4. MessageBox.Show("Please enter all the data before pressing Add");
  5. else
  6. {
  7. mamaDataSet.PacientRow pr;
  8. int maxId;
  9.  
  10. maxId = -1;
  11. foreach (mamaDataSet.PacientRow r in mamaDataSet.Pacient.Rows)
  12. {
  13. if (r.PacientId > maxId) maxId = r.PacientId;
  14. }
  15. maxId = maxId + 1;
  16.  
  17. pr = (mamaDataSet.PacientRow)mamaDataSet.Pacient.NewRow();
  18. pr.PacientId = maxId;
  19. pr.Name = name.Text;
  20. pr.Surname = surname.Text;
  21. bool b=false;
  22. try
  23. {
  24. pr.Age = int.Parse(age.Text);
  25. }
  26. catch (Exception es)
  27. {
  28. MessageBox.Show("Invalid age, please insert a number");
  29. b = true;
  30. }
  31. if (b != true)
  32. {
  33. DateTime startD = entryDate.SelectionStart;
  34. pr.EntryDate = startD;
  35. mamaDataSet.Pacient.Rows.Add(pr);
  36. //daProducts.Update(dsStore1, "Products");
  37. MessageBox.Show(maxId.ToString());
  38. pacientTableAdapter.Update(mamaDataSet);
  39. }
  40. }
  41. }

There at pacientTableAdapter.Update(mamaDataSet);, I tried with pacientTableAdapter.Insert(the_required_fields); but that didn't work either
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dustman is offline Offline
4 posts
since Mar 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: XmlSerializer issue.
Next Thread in C# Forum Timeline: Help regarding cell click event in datagridview





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC