October 24th, 2013, 12:43 PM
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:
I got this error:
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>"
Arguments are of the wrong type, are out of acceptable range... conflict with one another.
Can anyone help me to correct this?
October 24th, 2013, 03:52 PM
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
Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.