Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8603173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:15:43+00:00 2026-06-12T02:15:43+00:00

Im writing an application that updates a database that ive created. The application has

  • 0

Im writing an application that updates a database that ive created. The application has a datagridview on it which displays the data from the database.
Something very weird is going on with my app.

Here is the code that updates the database

string updateCommandString = "UPDATE RoomsTable SET [Date Checked]=@checkedDate WHERE      ID = @id"; 
using (OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\users\spreston\documents\visual studio 2012\Projects\roomChecksProgram\roomChecksProgram\roomsBase.accdb"))
{
    using (OleDbCommand updateCommand = new OleDbCommand())
    {
        updateCommand.Connection = conn;
        updateCommand.CommandText = updateCommandString;
        updateCommand.CommandType = CommandType.Text;
        updateCommand.Parameters.AddWithValue("@checkedDate", 
            this.dateTimePicker1.Value.ToShortDateString());
        updateCommand.Parameters.AddWithValue("@id", row.roomID);
        try
        {
            conn.Open();
            updateCommand.ExecuteNonQuery();
            conn.Close();
            conn.Dispose();
        }
        catch(OleDbException ex)
        {
            MessageBox.Show(ex.Message.ToString());
        }
    }
}

Now when I run that code, close out off the app, and run the app again, the changed are correctly displayed in my datagridview that is connected to the database, but when i look at the actual database, nothing has changed at all. I dont know why this is happening.

My sql update updates the database, which is connected to the datagrid view. Sow HOW is the datagrid view displaying the correct data but not the database itself.

edit:
I have had no sort of experience with sql before.

edit:
transaction code:

 string updateCommandString = "UPDATE RoomsTable SET [Date Checked]=@checkedDate WHERE ID = @id"; 
                using (OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\users\spreston\documents\visual studio 2012\Projects\roomChecksProgram\roomChecksProgram\roomsBase.accdb"))
                        {
                            OleDbTransaction transaction = null;
                         using (OleDbCommand updateCommand = new OleDbCommand())
                             {

                                    updateCommand.Connection = conn;
                                    updateCommand.Transaction = transaction;    
                                    updateCommand.CommandText = updateCommandString;
                                    updateCommand.CommandType = CommandType.Text;
                                    updateCommand.Parameters.AddWithValue("@checkedDate", this.dateTimePicker1.Value.ToShortDateString());
                                    updateCommand.Parameters.AddWithValue("@id", row.roomID);
                            try
                            {
                                conn.Open();
                                transaction = conn.BeginTransaction();
                                updateCommand.ExecuteNonQuery();
                                transaction.Commit();

                                conn.Close();
                                conn.Dispose();
                            }
                            catch(OleDbException ex)
                            {
                                MessageBox.Show(ex.Message.ToString());
                            }
                        }
                    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T02:15:45+00:00Added an answer on June 12, 2026 at 2:15 am

    Possible reasons:

    1. Your application may connect to copy of database file. Search your project directory for copies of database (.accdb extension?)
    2. Maybe David S is right, but you have to commit changes on database (OleDbTransaction help at MSDN). Changing isolation settings to READ UNCOMMITTED is inelegant approach to problem.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing an application that logs status updates (GPS locations) from devices to
I'm currently writing an application that displays a lot , and I mean, a
I'm writing a Java SE (desktop) application that has to access different databases all
I'm writing an application which aims to centralize all data related to project management
Hallo, I am writing a database application that does a lot of inserts and
I am writing an application that is basically a DataGrid attached to a database
I'm writing application for downloading CSV file from web and inserting data into table
I'm writing an application that is using a database (currently MySQL 4) to store
I am writing code to migrate data from our live Access database to a
I'm writing a database application where certain parts of the database might need updates

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.