Nicodemas
04-15-2003, 05:22 AM
I have a database table that is populated by an ADSI procedure. What I'm trying to do is grab all the local groups off my server, filter some out, and then populate the table with those groups, so that users will always have an up to date copy of the groups on the server to choose from.
However, one of the columns in this table should always stay the same. Take a look:
<%
'###################### DECLARE VARIABLES ################################################
Dim strSQL, ysnSuccess, intCounter
intCounter = 1
'################ DELETE ALL THE GROUPS ON THE SERVER FROM tblGroups #####################
strSQL = "DELETE txtGroup, intGroup FROM tblGroups"
ysnSuccess = adlExecuteSQL(strDB,strSQL,NULL)
If ysnSuccess = False Then
Response.Write "<CENTER><FONT COLOR='#FF0000' SIZE='+2'>The script failed to refresh the list of groups on the server. Contact your unit's page maintainer.</FONT></CENTER>"
%><!-- #INCLUDE VIRTUAL="/include/bottom.asp" --><%
End If
'#### USES ADSI TO GRAB THE AVAILABLE USERGROUPS FROM THE SERVER AND POPULATES THE DATABASE WITH THEM ###########
strServer="SPM-INTRANET-01"
Set objServer = GetObject("WinNT://" & strServer)
objServer.Filter = Array("group")
For Each colGroup In objServer
If colGroup.Class = "Group" Then
If colGroup.Name <> "Administrators" AND colGroup.Name <> "Backup Operators" AND colGroup.Name <> "Guests" AND colGroup.Name <> "Power Users" AND colGroup.Name <> "Replicator" AND colGroup.Name <> "Users" Then
strSQL = "INSERT INTO tblGroups (txtGroup, intGroup) VALUES ('" & colGroup.Name & "', "& intCounter & ")"
ysnSuccess = adlExecuteSQL(strDB,strSQL,NULL)
intCounter = intCounter+1
End If
End If
Next
Set objServer = Nothing
Set colGroup = Nothing
%>
The SQL statement on line 9 DELETES two fields from my table: field "txtGroup" and field "intGroup", but I need the third field, "HasPrimary" to remain untouched.
Each time this script runs, though, HasPrimary is deleted and then reinstated with it's value changed back to False, whereas it needs to remain True if it was so...
How should I go about changing my SQL statement and thus get this whole script running correctly?
However, one of the columns in this table should always stay the same. Take a look:
<%
'###################### DECLARE VARIABLES ################################################
Dim strSQL, ysnSuccess, intCounter
intCounter = 1
'################ DELETE ALL THE GROUPS ON THE SERVER FROM tblGroups #####################
strSQL = "DELETE txtGroup, intGroup FROM tblGroups"
ysnSuccess = adlExecuteSQL(strDB,strSQL,NULL)
If ysnSuccess = False Then
Response.Write "<CENTER><FONT COLOR='#FF0000' SIZE='+2'>The script failed to refresh the list of groups on the server. Contact your unit's page maintainer.</FONT></CENTER>"
%><!-- #INCLUDE VIRTUAL="/include/bottom.asp" --><%
End If
'#### USES ADSI TO GRAB THE AVAILABLE USERGROUPS FROM THE SERVER AND POPULATES THE DATABASE WITH THEM ###########
strServer="SPM-INTRANET-01"
Set objServer = GetObject("WinNT://" & strServer)
objServer.Filter = Array("group")
For Each colGroup In objServer
If colGroup.Class = "Group" Then
If colGroup.Name <> "Administrators" AND colGroup.Name <> "Backup Operators" AND colGroup.Name <> "Guests" AND colGroup.Name <> "Power Users" AND colGroup.Name <> "Replicator" AND colGroup.Name <> "Users" Then
strSQL = "INSERT INTO tblGroups (txtGroup, intGroup) VALUES ('" & colGroup.Name & "', "& intCounter & ")"
ysnSuccess = adlExecuteSQL(strDB,strSQL,NULL)
intCounter = intCounter+1
End If
End If
Next
Set objServer = Nothing
Set colGroup = Nothing
%>
The SQL statement on line 9 DELETES two fields from my table: field "txtGroup" and field "intGroup", but I need the third field, "HasPrimary" to remain untouched.
Each time this script runs, though, HasPrimary is deleted and then reinstated with it's value changed back to False, whereas it needs to remain True if it was so...
How should I go about changing my SQL statement and thus get this whole script running correctly?