473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to update Access Database in C#?

103 100+
I am developing an application and all of my code reads and inserts into an mdb database file. However when I try to update, the code executes without issue, but when I check the database, the updates are not there. Here is my update code:
Expand|Select|Wrap|Line Numbers
  1.             else if(isNewEntry == false)
  2.             {
  3.                 string query = "UPDATE hours SET hoursWorked = @p3 WHERE contactID = @p1 AND fiscalYearID = @p2";
  4.                 cmd.CommandText = query;
  5.                 foreach (DataGridViewRow row in dgvTime.Rows)
  6.                 {
  7.  
  8.                     id = Convert.ToInt16(row.Cells["contactID"].Value);
  9.                     hours = Convert.ToInt16(row.Cells["hoursWorked"].Value);
  10.                     year = yr;// Convert.ToInt16(cbFiscalYear.SelectedIndex.ToString()); 
  11.                     cmd.Parameters.AddWithValue("@p1", id.ToString());
  12.                     cmd.Parameters.AddWithValue("@p2", year.ToString());
  13.                     cmd.Parameters.AddWithValue("@p3", hours.ToString());
  14.                     cmd.Connection.Open();
  15.                     cmd.ExecuteNonQuery();
  16.                     cmd.Parameters.Clear();
  17.                     cmd.Connection.Close();
  18.                     pbEnteringData.PerformStep();
  19.                 }
  20.                 pbEnteringData.Value = 0;
Any help would be greatly appreciated.
Jan 24 '14 #1
0 1064

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Nono | last post by:
Hello, I am trying to update records in my database from excel data using vba editor within excel. In order to launch a query, I use SQL langage in ADO as follwing:...
1
by: Shawn Jackson via .NET 247 | last post by:
Hi, I just starting using VB.NET and I a few textboxes on a form. I want to enter info into the textboxes, click the Add Button and update my Access database. Can't get it to work. Maybe someone has...
2
by: AccessWannaBe | last post by:
Can anyone spare a good example of how to update a specific field in a row within a table in an access database? I am good with fetching the data and representing in a table, but what if I want to...
15
by: philip | last post by:
On a form, I have a datagridview. This datagridview is constructed on a dataset filled by a tableadapter. The table adapter do very well what it must do when filling dataset. Insertions,...
4
by: George | last post by:
Hi all, I am having trouble with updating my data in an Access database. here is my code: Imports System.Data.OleDb Dim AppPath As String = Mid(Application.ExecutablePath, 1,...
1
by: amindi | last post by:
Hi, I wrote a VB6 program to read some data records from a Ms Access database and to write them into a SQL server database.(I use Ms Access 2000 and SQL server 2000).After reading each record in...
5
by: John | last post by:
I have an ASP.NET 2.0 application developed in VB.net, that accesses an Microsoft Access database. When the database is on the same IIS server all works just fine. BUT when it tried to access the...
1
by: tazdiver | last post by:
Hi All, I am having an issue with an windows application made from VB.NET 2003 which is using an access database. Basically the problem is that when the user updates a field on the app from a...
1
by: tazdiver | last post by:
Hi All, I am having an issue with an windows application made from VB.NET 2003 which is using an access database. Basically the problem is that when the user updates a field on the app from a...
1
by: =?Utf-8?B?QW5kcmU=?= | last post by:
I used the wizard in VS2005 to create my connection, dataset, and tableadaptor I have a typed dataset named dsUserInfo I have a tableadaptor named taFillUserInfo I would like to on the vb side...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.