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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:08:21+00:00 2026-05-30T16:08:21+00:00

I have an application that works with a database that uses foreign key constraints.

  • 0

I have an application that works with a database that uses foreign key constraints.

For example, we have an inventory table that has a foreign key constraint that references a table called case_names. If a user attempts to delete a case name that has any inventory items referencing it’s ID, the action is restricted.

How can I display a message to the user that they will understand? ‘You can not delete this case as it still contains inventory items.’

My thought is a try-catch (catching different error types?) but I do not really want to use this for something that may be expected.

The application is in VB.Net using MySQL.data

  • 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-05-30T16:08:23+00:00Added an answer on May 30, 2026 at 4:08 pm

    I wouldn’t use exceptions to handle user errors or normal program flow.
    Just check if the user can delete the records (using maybe a stored procedure), and if not show her an alert message.

    I think exceptions are for errors you can’t foresee.

    edit to clarify:

    The stored procedure (or the code in your program) can do the checks on all the involved tables or it can even COUNT() how many records would be affected by the deletion request. By counting you have the added benefit of telling the user how many inventory items are connected with the case, in you example:

    “You can not delete this case as it still contains 32 inventory
    items.”

    edit to clarify more:

    This isn’t to say that reference integrity shouldn’t be properly set up in the DB, of course. If you forget some checks still you have the DB that works for your (and the user will call you to know what the heck the program is saying 🙂 ).

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

Sidebar

Related Questions

I have an application that uses a SQLite database and everything works the way
I have a web application project that works with a quite large database (over
I have an C# form application that use an access database. This application works
We have an application that works with MS Office and uses Microsoft.mshtml.dll. We use
I have an application that uses a database on SQL Server and I want
I have an application that uses SMO to manage databases. It works great on
I have written an Android application that uses SQLite database which is saved in
We have an ASP.NET application that uses SQL statements, where table names are unqualified.
I have written a simple Android application that uses a sqlite database which is
I have built a WP7.1 application that uses a local database. I used sqlmetal

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.