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

    Join Date
    Aug 2008
    Rep Power

    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:
    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?

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

    Join Date
    Jun 2003
    Rep Power
    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
    I've never been able to appreciate the sublime arrogance of folks who feel they were put on earth just to save other folks from themselves .." - Donald Hamilton

IMN logo majestic logo threadwatch logo seochat tools logo