#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2008
    Posts
    28
    Rep Power
    0

    How to delete records from two tables?


    I have data in two tables, Students and Department. There may be some students in Department table.
    I tried to delete a student (for example: ID: 10) from student table, at the same time, the Student with ID: 10 (may have more than 1 records) will be deleted from Department table.

    Here is my code:
    Action.asp
    Code:
    <%
    
    Dim Student_ID, rsDel, myCon
    Student_ID = Request.Querystring("ID")
    Set rsDel = Server.CreateObject("adodb.Recordset")
    strSQL = "  delete FROM Students Where Student_ID = " & Student_ID & ";"
    strSQL = "  delete FROM Department Where Student_ID = " & Student_ID & ";"
    rsDel.Open strSQL, myCon
    rsDel.lockType = 2
    Response.Write "<br /><center><b>Student Deleted</b></center>"
    %>
    I got this error:
    Arguments are of the wrong type, are out of acceptable range... conflict with one another.

    Can anyone help me to correct this?

    Thanks.
  2. #2
  3. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,453
    Rep Power
    4539
    Check that your Student_ID variable contains the number you expect. You can use response.write to help debug.
    Also double-check that the column name in your database is also Student_ID
    ======
    Doug G
    ======
    Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.
    --Alfred Bester

IMN logo majestic logo threadwatch logo seochat tools logo