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 8756753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:08:53+00:00 2026-06-13T14:08:53+00:00

I just learn Visual Studio C# for 2 months. Recently, I write the code

  • 0

I just learn Visual Studio C# for 2 months. Recently, I write the code that can connect with Microsoft Access 2007 and it run smoothly (it can show data and can delete record as I expect) However, when I build the project, it still show data but cannot delete record.(it show error message box “Unhandled exception has occurred in your application. If you click Continue, the application will ignore this error and attempt to continue. If you click Quit, the application will close immediately”)
I don’t know what’s wrong with it. I try many ways for the solution but not yet succeed.
I upload the project to 4shared.com so please download by this link –>
http://www.4shared.com/zip/bxhZC3Wp/WindowsFormsApplication32.html?

After download, please open and try running the code (file name WindowsFormsApplication32)
you will see 3 textboxes, type 1 and click button1, it will show name in textbox2 and city in textbox3. Now click button2 to delete the record, you can see that it will delete the record successfully. Then, open the folder iii>Debug, install the program (file name iii),and open the program (may located at C:\Program Files (x86)\Default Company Name\iii). You can try the same way as when you run the code but after click button2 to delete the record, it will show messagebox error (please download the picture of the message error by this link –> http://www.4shared.com/photo/FgUODfoW/error_messagebox.html? )
Anyone please help me.

PS. This is how I Build the project.

  1. Open Visual Studio2010 by Right Click and select ‘Run as
    administrator’.
  2. Open my project
  3. ‘File’ > ‘Add’ > ‘New Project’
  4. In ‘Add New Project’ Window, select ‘Other Project Types’>’Setup and Deployment’> ‘Visual Studio Installer’ select ‘Setup Project’
  5. In ‘File System’ tab, right click ‘Application Folder’> ‘Add’ > ‘Project Output…’
  6. In ‘File System’ tab, right click ‘Application Folder’> ‘Add’ > ‘File…’ and select my Microsoft Access 2007’s file.
  7. in ‘Solution Explorer’ window, right click my project and select ‘Build’
    Is this way can import the database to my project correctly?

Below is the code.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;

namespace WindowsFormsApplication32
{
public partial class Form1 : Form
  {
    public Form1()
    {
        InitializeComponent();
    }
    private OleDbConnection connection;
    private OleDbDataAdapter adapter;

    private OleDbCommand command;
    private string sql;

    private void Form1_Load(object sender, EventArgs e)
    {
        string con = @"Provider=Microsoft.ACE.OLEDB.12.0;
                        Data Source=|DataDirectory|\bbb.accdb;
                        Persist Security Info=False;";
        connection = new OleDbConnection(con);
        if (connection.State == ConnectionState.Closed)
            connection.Open();
    }

    private void button1_Click(object sender, EventArgs e)
    {

        sql = "SELECT * FROM test WHERE id=" + textBox1.Text;

        command = new OleDbCommand(sql, connection);

        adapter = new OleDbDataAdapter(command);
        DataSet data = new DataSet();
        adapter.Fill(data, "abc");
        if (data.Tables["abc"].Rows.Count == 0) return;

        else
        {

            textBox2.Text = Convert.ToString(data.Tables["abc"].Rows[0]["Name"]);
            textBox3.Text = Convert.ToString(data.Tables["abc"].Rows[0]["City"]);
        }


    }

    private void button2_Click(object sender, EventArgs e)
    {
        DialogResult result = MessageBox.Show("are you sure to delete", "delete", MessageBoxButtons.OKCancel);
        if (result == DialogResult.Cancel) return;
        sql = "DELETE FROM test WHERE ID=" + textBox1.Text;
        command = new OleDbCommand(sql, connection);
        int r = (int)command.ExecuteNonQuery();
        if (r > 0)
        {
            MessageBox.Show("already delete");
            textBox1.Text = "";
            textBox2.Text = "";
            textBox3.Text = "";
        }
        else MessageBox.Show("error to delete");


        }
    }
}
  • 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-13T14:08:55+00:00Added an answer on June 13, 2026 at 2:08 pm

    The error is because of the folder permissions. If you are using Window 7, after you installed the application, go to the installed directory and right click on the executable. Click on “Run as administrator” and now try deleting the record. This time it will be successful.

    Alternate method to work in any OS
    Provide modify permission to local system Users (MYPC\Users) and try again. It will work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just starting to learn ASP.NET (C#) and I am using Visual Studio 2008. I
Can one learn programming in VB.net using Visual Studio (Winforms stuff) and never learn
I want to write a web service using Visual Studio. The service needs to
I am trying to learn Windows.Forms, and while I have Visual Studio (edit, my
I don't want to download Visual Studio 2010. How can I start studying (not
Tools: Visual Studio 2010 I'm trying to learn jQuery, but I cant make this
I have just gotten Visual Studio 2010 Pro Academic Version today with the MSDN
I have just started to learn asp.net MVC3 and i run into this problem:
Hi I'm new to Visual Studio.NET.I saw a tutorial but I can't see any
I want to write a MySql statement that will connect to the database, select

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.