Thanks Axl1971
So can we have one subroutine inside the other?
sub SetMerakiUpDownTime (sNet)
set http=createObject("Microsoft.XMLHTTP")
http.open "GET",sUrl,false
http.setRequestHeader "Content-Type","application/json"
http.setRequestHeader "Accept","application/json"
http.setRequestHeader "X-Cisco-Meraki-API-Key",xAPIKey
http.send
responseText=http.responseText
If http.Status = 200 Then
apiData = Split(responseText , ",")
For i = 0 to Ubound(apiData)
Sub MerakiUpDownStatsToDb()
Dim conn
Set conn = createobject("Adodb.Connection")
Dim sConnString
Dim SqlStatement
sConnString = "Provider=SQLOLEDB;Data Source=" & SQLServer01 & "; Initial Catalog=" & MerakiDB & "; Integrated Security=SSPI;"
conn.Open sConnString
conn.CommandTimeout = 900
StartScript
set http=createObject("Microsoft.XMLHTTP")
http.open "GET",sUrl,false
http.setRequestHeader "Content-Type","application/json"
http.setRequestHeader "Accept","application/json"
http.setRequestHeader "X-Cisco-Meraki-API-Key",xAPIKey
http.send
responseText=http.responseText
If http.Status = 200 Then
apiData = Split(responseText , ",")
For i = 0 to Ubound(apiData)
NEXT
call WriteSQL(x,y,z)
sub writeSQL(Location,DeviceName,UpTime,DownTime)
On Error Resume Next
Dim conn
Set conn = createobject("Adodb.Connection")
Dim sConnString
Dim SqlStatement
sConnString = "Provider=SQLOLEDB;Data Source=" & SQLServer01 & "; Initial Catalog=" & MerakiDB & "; Integrated Security=SSPI;"
conn.Open sConnString
conn.CommandTimeout = 900
SqlStatement = "INSERT INTO [dbo.TheTable] " & _"(Location,DeviceName,UpTime,DownTime) VALUES (Location,DeviceName,UpTime,DownTime)"
conn.Execute(SqlStatement)
conn.close
Set conn = Nothing
If Err.Number <> 0 Then
WScript.Echo "Error Writing to SQL " & Err.Description
Err.Clear
End If
End Sub
End If
end sub