I’m getting Incorrect Syntax Near ')'
The line it references is oCN.Execute(sSQL) towards the very end.
Syntactically, if I remove either line within For Each objItem in colItems it will not throw an error.
Is it not possible to execute a SQL query using objects from the WMI Service? Or am I making an error somewhere else?
I can list more code upon request; i’m trying to keep it simple for now.
Set oCN = CreateObject("ADODB.connection")
sCN = "Provider=SQLOLEDB; Data Source=" & oRS("sql_server_instance") & ";Initial Catalog=master;Integrated Security=SSPI;"
oCN.Open sCN
'Gather disk information from WMI Service
Set oWMIService = GetObject("winmgmts:\\" & oRS("sql_server") & "\root\cimv2")
Set colItems = oWMIService.ExecQuery _
("Select * From Win32_Volume")
'Loop through all disks
For Each objItem in colItems
sSQL="insert into HDS_DBA_DB.[dbo].[TEMP_disk_info_table] (drive_letter, capacity) " &_
"values('" & objItem.DriveLetter & "'," & objItem.Capacity & ")"
oCN.Execute(sSQL)
Next
It seems which the problem is in the
objItem.Capacityproperty, check the value of this property before to insert because the value can be empty and that produces an incorrect SQL sentence like