squarefish
08-16-2010, 05:17 AM
The code below works fine as a vbs file, but when I try and use it as an active x script within sql2005 I get the above error saying not all the objects were destroyed???
as far as I can see all my set something = have a set something = nothing?
Any ideas?
option explicit
dim MM_stock_STRING, MM_CAP_STRING, MM_CAP2_STRING, rs, regplate, capid, rsCap, sql, manufacturer
dim range, derivative, fueldelivery, drivetrain, transmission, doors, bodystyle, optionActual
dim MM_editCmd, rsCap2
'get all cars with a cap id
set rs = CreateObject("ADODB.Recordset")
rs.ActiveConnection = MM_stock_STRING
rs.Source = mysql
rs.CursorType = 2
rs.CursorLocation = 2
rs.LockType = 1
rs.Open()
'Loop through the cars
do until rs.EOF
set rsCAP = CreateObject("ADODB.Recordset")
rsCAP.ActiveConnection = MM_CAP_STRING
sql = mysql
rsCAP.Source = sql
rsCAP.CursorType = 2
rsCAP.CursorLocation = 2
rsCAP.LockType = 1
rsCAP.Open()
if not rsCAP.EOF then
'write results back to db
Set MM_editCmd = CreateObject("ADODB.Command")
sql = mysql
MM_editCmd.ActiveConnection = MM_stock_STRING
MM_editCmd.CommandText = sql
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
Set MM_editCmd = NOTHING
'reset optionActual
optionActual=""
else
set rsCAP2 = CreateObject("ADODB.Recordset")
rsCAP2.ActiveConnection = MM_CAP2_STRING
sql = sql
rsCAP2.Source = sql
rsCAP2.CursorType = 2
rsCAP2.CursorLocation = 2
rsCAP2.LockType = 1
rsCAP2.Open()
'loop through the optionActual and append to string
if not rsCAP2.EOF then
'write results back to car
Set MM_editCmd = CreateObject("ADODB.Command")
sql = mysql
MM_editCmd.ActiveConnection = MM_stock_STRING
MM_editCmd.CommandText = sql
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
Set MM_editCmd = Nothing
optionActual=""
else
'delete and alert
Set MM_editCmd = CreateObject("ADODB.Command")
sql = mysql
MM_editCmd.ActiveConnection = MM_stock_STRING
MM_editCmd.CommandText = sql
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
Set MM_editCmd = Nothing
end if
rsCAP2.Close()
SET rsCAP2 = Nothing
end if
rsCAP.Close()
SET rsCAP = Nothing
rs.MoveNext
Loop
rs.Close
set rs=nothing
as far as I can see all my set something = have a set something = nothing?
Any ideas?
option explicit
dim MM_stock_STRING, MM_CAP_STRING, MM_CAP2_STRING, rs, regplate, capid, rsCap, sql, manufacturer
dim range, derivative, fueldelivery, drivetrain, transmission, doors, bodystyle, optionActual
dim MM_editCmd, rsCap2
'get all cars with a cap id
set rs = CreateObject("ADODB.Recordset")
rs.ActiveConnection = MM_stock_STRING
rs.Source = mysql
rs.CursorType = 2
rs.CursorLocation = 2
rs.LockType = 1
rs.Open()
'Loop through the cars
do until rs.EOF
set rsCAP = CreateObject("ADODB.Recordset")
rsCAP.ActiveConnection = MM_CAP_STRING
sql = mysql
rsCAP.Source = sql
rsCAP.CursorType = 2
rsCAP.CursorLocation = 2
rsCAP.LockType = 1
rsCAP.Open()
if not rsCAP.EOF then
'write results back to db
Set MM_editCmd = CreateObject("ADODB.Command")
sql = mysql
MM_editCmd.ActiveConnection = MM_stock_STRING
MM_editCmd.CommandText = sql
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
Set MM_editCmd = NOTHING
'reset optionActual
optionActual=""
else
set rsCAP2 = CreateObject("ADODB.Recordset")
rsCAP2.ActiveConnection = MM_CAP2_STRING
sql = sql
rsCAP2.Source = sql
rsCAP2.CursorType = 2
rsCAP2.CursorLocation = 2
rsCAP2.LockType = 1
rsCAP2.Open()
'loop through the optionActual and append to string
if not rsCAP2.EOF then
'write results back to car
Set MM_editCmd = CreateObject("ADODB.Command")
sql = mysql
MM_editCmd.ActiveConnection = MM_stock_STRING
MM_editCmd.CommandText = sql
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
Set MM_editCmd = Nothing
optionActual=""
else
'delete and alert
Set MM_editCmd = CreateObject("ADODB.Command")
sql = mysql
MM_editCmd.ActiveConnection = MM_stock_STRING
MM_editCmd.CommandText = sql
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
Set MM_editCmd = Nothing
end if
rsCAP2.Close()
SET rsCAP2 = Nothing
end if
rsCAP.Close()
SET rsCAP = Nothing
rs.MoveNext
Loop
rs.Close
set rs=nothing