Results 1 to 5 of 5

Thread: Deleting records using the application?

  1. #1
    Join Date
    Jul 2010
    Posts
    26

    Deleting records using the application?

    Launch a SQL query deletion is quite simple, but the problem I encounter is how to make the pre-treatment removed. Suppose that is a table that relates PEOPLE by a field to another table TUITION, then I do not think. I check if it exists in each of the tables before deleting? or else, Delete it and when you paste the treat? This function I have not implemented this, and since I have almost the application list I would like to leave it closed.

  2. #2
    Join Date
    Jan 2009
    Posts
    99

    Re: Deleting records using the application?

    Good in that case if a query in question and delete the other two trips to the server, if you try to remove without question is just a trip, also if your database is relational and is well designed for referential integrity will not let you delete, so you do not perform the deletion, also an important thing, not try to remove, loq the command you must yield is the number of rows affected, if you cannot delete it return a 0, so no exception is thrown at the level of application, single database, then you can do in one, and if it returns 0 then it will not delete.

  3. #3
    Join Date
    Mar 2008
    Posts
    227

    Re: Deleting records using the application?

    Well do not know what database you are using but for example MySQL has an option to create referential integrity when you update or delete cascade, meaning that if you update the parent table, child tables are also updated, as happens with elimination. Well then in that case what I normally do is go first go to all child tables that have parent table and delete those belonging and finally delete the parent record. Example:
    You invoice header and invoice detail together for the code_invoice, then delete the records that are in the invoice detail and finally the header to avoid errors with referential integrity.

  4. #4
    Join Date
    Mar 2008
    Posts
    258

    Re: Deleting records using the application?

    In this case and that would be for validation, that is looking for students in that course and if you find you could tell the program that allows you to delete. For example, have a student table with cod_student and name_student as fields, and then there are the table with the fields assigned_course_students cod_student and course_student. Then the time to remove any student questions.
    Code:
    sql = "select * from WHERE assigned_course_Students code_student = '" & txtstudent.text & "'" / / where txtstudent who has the code to remove 
    
    dim cmd as new odbc.odbccommand (sql, connection) 
    
    dr = cmd.executreader () 
    
    // Valid here 
    
    Then if dr.Read 
    
    msgbox "This student belongs to a course and cannot be deleted" 
    
    else 
    
    sql = "delete from assigned_course_Students WHERE code_student = '" & txtstudent.text & "'" 
    
    ' 
    
    ' 
    
    '

  5. #5
    Join Date
    Oct 2008
    Posts
    167

    Re: Deleting records using the application?

    If tables in the database are well designed and properly connected, just using the cascade delete orphan records not to leave. If you have an Invoices table and another Invoices Detail that are related by common Invoice Id, and delete an invoice, what do you want to continue taking the details of that bill? But this is a different issue that has nothing to do with allowing or not cascade delete. If you do not want to remove a student currently enrolled in a course, do not choice but to see if that student is currently enrolled in a course. The answer is yes? Does not eliminate the student's record. The answer is negative? Eliminate the student's record and those records in related tables, that's what you would cascade delete. However, if the database is poorly designed, as you may have problems. And now I ask you to you. Have you thought well it's possible to remove students and the courses you have taught? Imagine that tomorrow is by the student and wish to obtain a certificate of the courses you have done. If you deleted the student and that student-related courses, What certificate are you going to give? I warn you delete records is an issue that can be very delicate. Can you imagine that a public body remove the information from any of us? Some, like you would "pearl", but others, like they feel affected.

Similar Threads

  1. Searching for Records in VB 6.0
    By Lustrous in forum Software Development
    Replies: 4
    Last Post: 26-12-2010, 08:47 AM
  2. Replies: 4
    Last Post: 20-04-2010, 11:56 AM
  3. DNS Server dot deleting old records
    By Nickason in forum Active Directory
    Replies: 2
    Last Post: 29-01-2010, 08:45 PM
  4. Problem deleting a widget application in HTC Tattoo
    By Arzaan in forum Portable Devices
    Replies: 2
    Last Post: 26-12-2009, 04:05 PM
  5. Replies: 1
    Last Post: 24-08-2009, 09:47 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,691,785.30364 seconds with 17 queries