Forums

This topic is locked

INVALID COLUMN NAME

Posted 11 Nov 2004 12:14:07
1
has voted
11 Nov 2004 12:14:07 Matt Jukes posted:
Hello,

This project uses MSSQL and ASP.

I have a Table of Tasks, Each Task is assigned a Group.
What I want is when the task is deleted a SQL statement checks if there are any other tasks from the group assigned to the initial task. If there are no more tasks in that group then I want to delete the group name from a Second table holding only group names.

My SQL statement below shows what i have so far, This works fine and deletes the task but when the second stage for checking teh groups starts I have an error stating 'Invalid Column Name' and then the group name which i was checking for. eg. Invalid Column Name GroupName

Dim strSQL, rstTaskGroup, rstTaskDelete, rstGroup, rstGroupDelete, varGroup

If NOT Request.Form("actionChk" = "" Then

strSQL = "SELECT groupName FROM tbltask WHERE taskId = " & Request.Form("actionChk"
Set rstTaskGroup = objADODB.Execute(strSQL)

varGroup = rstTaskGroup("groupName"

Set rstTaskDelete = objADODB.Execute("DELETE FROM tbltask WHERE taskId IN (" & Request.Form("actionChk" & ""

strSQL = "SELECT groupName FROM tblgroup WHERE groupName = " & varGroup
Set rstGroup = objADODB.Execute(strSQL)

If rstGroup.EOF Then
Set rstGroupDelete = objADODB.Execute("DELETE FROM tblgroup WHERE groupName IN" & varGroup)
End If

End If

I obviously have a problem with the variables I have defined as the initial groupName but i can't find any help to say how else to use the variables in this situation.

If anyone has any ideas or comments they would be greatly appreciated. Thanks in Advance

Matt

Reply to this topic