We've updated to Preview version 16.2.24.3624+. I wanted to add the new ADO SQL v2 Sensor to replace our depricated old ADO SQL Sensors, but I get the error message "An item with the same key has already been added." everytime, no matter what connection string I use (Postgres, MS SQL, ...). Is there any way to fix it?


Article Comments

Same issue here.


May, 2016 - Permalink

Hello,

We are able to reproduce this in the PRTG stable and Preview version and can confirm this is a current bug. We will be providing a fix for the same in a few days.

Please bear with us.


May, 2016 - Permalink

If anyone needs a ADO SQL sensor right now, I wrote a VBScript:

On Error Resume Next

Set objDBCommunicator = new DBCommunicator

Set objArgs 		= Wscript.Arguments
Set objConnection	= CreateObject("ADODB.Connection")
Set objRecordSet	= CreateObject("ADODB.RecordSet")

strPRTGStart 	=	"<prtg>"
strPRTGEnde 	=	"</prtg>"

Class DBCommunicator
	Public Function DBConnect(StrCon)
		On Error Resume Next
		
		objConnection.Open StrCon
		If Err.Number = 0 then
			DBConnect = True
		Else
			DBConnect = False
		End If
	End Function

	Public Function QueryDB(StrQuery)
		objRecordSet.Open StrQuery, objConnection
		If Err.Number = 0 then
			Do Until objRecordSet.EOF
				For each objField in objRecordSet.Fields
					If objField.Name = "" Then
						'Wscript.Echo "Wert" & " = " & objField.Value
						QueryDB = QueryDB	&	"	<result>" & VBCRLF
						QueryDB = QueryDB	&	"		<channel>" & strChannelNameCount & "</channel>" & VBCRLF
						QueryDB = QueryDB	&	"		<value>" & objField.Value & "</value>" & VBCRLF
						QueryDB = QueryDB	&	"	</result>" & VBCRLF
						'Wscript.Echo QueryDB
					Else
						'Wscript.Echo objField.Name & " = " & objField.Value
						QueryDB = QueryDB	&	"	<result>" & VBCRLF
						QueryDB = QueryDB	&	"		<channel>" & objField.Name & "</channel>" & VBCRLF
						QueryDB = QueryDB	&	"		<value>" & objField.Value & "</value>" & VBCRLF
						QueryDB = QueryDB	&	"	</result>" & VBCRLF
						'Wscript.Echo QueryDB
					End If
					
				Next
				objRecordSet.MoveNext
			loop
		Else
			QueryDB = QueryDB		&	"	<error>1</error>" & VBCRLF
			QueryDB = QueryDB		&	"	<text>Database Connect failed, please check parameters: " & chr(34) & "ADO SQL connectstring" & chr(34) & " , " & chr(34) & "SQL Query" & chr(34) & " , " & chr(34) & "Channel Name for Count" & chr(34) & "</text>" & VBCRLF
		End If
	End Function

	Public Function DBdisConnect
		objRecordSet.close
		objConnection.close
	End Function
End Class

'########################################

'objArgs(0)=Connectstring - "Provider=SQLOLEDB;Integrated Security=SSPI;Persist Security Info=False;Data Source=Server\Instance;Initial Catalog=DB;"
'objArgs(1)=SQL Query -     "select count(*) Schema.Computers;"
'objArgs(2)=Channel Name when Count in Query - "PCs"

Wscript.Echo "Number of parameters: " & objArgs.Count
Wscript.Echo ""
If objArgs.Count < 2 then
		strPRTGError = strPRTGError		&	"	<error>1</error>" & VBCRLF
		strPRTGError = strPRTGError		&	"	<text>Not enough parameters, please add or check parameters: " & chr(34) & "(Required) ADO SQL connectstring" & chr(34) & " , " & chr(34) & "(Required) SQL Query" & chr(34) & " , " & chr(34) & "(Optional) Channel Name for Count" & chr(34) & "</text>" & VBCRLF
ElseIf objArgs.Count = 2 then
	If InStr(LCase(objArgs(1)), "count(*)", 1) = True Then
		strPRTGError = strPRTGError		&	"	<error>1</error>" & VBCRLF
		strPRTGError = strPRTGError		&	"	<text>Count(*) in parameters, please add or check parameters: " & chr(34) & "(Required) ADO SQL connectstring" & chr(34) & " , " & chr(34) & "(Required) SQL Query" & chr(34) & " , " & chr(34) & "(Optional) Channel Name for Count" & chr(34) & "</text>" & VBCRLF
	Else
		strConnectString	= objArgs(0)
		strSQLQuery			= objArgs(1)
		strChannelNameCount	= ""
		
		strResult=objDBCommunicator.DBConnect(strConnectString)
		If strResult <> True Then
			strPRTGError = strPRTGError		&	"	<error>1</error>" & VBCRLF
			strPRTGError = strPRTGError		&	"	<text>Database connect failed, please check parameters: " & chr(34) & "(Required) ADO SQL connectstring" & chr(34) & " , " & chr(34) & "(Required) SQL Query" & chr(34) & " , " & chr(34) & "(Optional) Channel Name for Count" & chr(34) & "</text>" & VBCRLF
		ElseIf strResult = True Then
			strPRTGChannnel = objDBCommunicator.QueryDB(strSQLQuery)
			objDBCommunicator.DBdisConnect
		End If
	End If
ElseIf objArgs.Count = 3 then
	strConnectString	= objArgs(0)
	strSQLQuery			= objArgs(1)
	strChannelNameCount	= objArgs(2)
	
	strResult=objDBCommunicator.DBConnect(strConnectString)
	If strResult <> True Then
		strPRTGError = strPRTGError		&	"	<error>1</error>" & VBCRLF
		strPRTGError = strPRTGError		&	"	<text>Database Connect failed, please check parameters: " & chr(34) & "(Required) ADO SQL connectstring" & chr(34) & " , " & chr(34) & "(Required) SQL Query" & chr(34) & " , " & chr(34) & "(Optional) Channel Name for Count" & chr(34) & "</text>" & VBCRLF
	ElseIf strResult = True Then
		strPRTGChannnel = objDBCommunicator.QueryDB(strSQLQuery)
		objDBCommunicator.DBdisConnect
	End If
End If

If InStr(strPRTGError,"<error>1</error>") Then
	strPRTG = strPRTGError
ElseIf InStr(strPRTGChannnel,"<error>1</error>") Then
	strPRTG = strPRTGChannnel
Else
	strPRTG = strPRTGChannnel
End If

wscript.echo strPRTGStart
wscript.echo strPRTG
wscript.echo strPRTGEnde

Maybe it helps as long as we wait for the fix.


May, 2016 - Permalink

Hi there We have the same issue

thanks Ash


May, 2016 - Permalink

Hello,

We released the PRTG version 16.2.24.3791/3792 yesterday evening with the bigfix for the SQL v2 sensors. Please update to this version to solve the issue.


May, 2016 - Permalink

I am now seeing that problem with PRTG Network Monitor 16.4.27.6720+


Oct, 2016 - Permalink

Please go to the sensor's settings, and Configure the "DEBUG OPTION" "Write sensor result to disk(Filename: Result of Sensor [ID].txt" The log will be written on the probe that monitors that sensor under (%ProgramData%\Paessler\PRTG Network Monitor\Logs (Sensors)) and send the result file to Support@paessler.com Please refer to this kB-article.


Oct, 2016 - Permalink