i cant save data on an access database

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Feb 2007
Posts: 3
Reputation: fruce is an unknown quantity at this point 
Solved Threads: 0
fruce fruce is offline Offline
Newbie Poster

i cant save data on an access database

 
0
  #1
Feb 16th, 2007
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
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 47
Reputation: kapil.goyal is an unknown quantity at this point 
Solved Threads: 0
kapil.goyal kapil.goyal is offline Offline
Light Poster

Re: i cant save data on an access database

 
0
  #2
Feb 16th, 2007
i hav to look into ur code wat exactly it is doing .so post the prob along with the code
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 3
Reputation: fruce is an unknown quantity at this point 
Solved Threads: 0
fruce fruce is offline Offline
Newbie Poster

Re: i cant save data on an access database

 
0
  #3
Feb 16th, 2007
Originally Posted by kapil.goyal View Post
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
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 4
Reputation: dustman is an unknown quantity at this point 
Solved Threads: 0
dustman dustman is offline Offline
Newbie Poster

Re: i cant save data on an access database

 
0
  #4
Sep 28th, 2007
hello....i have the same problem...the button for the Save buttons looks like this:
  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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC