HI,
I buy a SNMP board for my project and i got some problem to understand SNMP code with VB, Can somenone help me?, i got this code under another project, and i want to use it in my project but, when i copy and paste it in my project, this code got many error, can someone help me to explain it why?
Private Sub snmpSet(ByVal IPaddress As String, ByVal Port As Integer, ByVal OID As String, ByVal dataType As SByte, ByVal SetValue As String, ByVal Community As String)
Dim objAPI As adventnet.snmp.snmp2.SnmpAPI = New adventnet.snmp.snmp2.SnmpAPI
Dim objSession As adventnet.snmp.snmp2.SnmpSession = New adventnet.snmp.snmp2.SnmpSession(objAPI)
Dim objPDU As adventnet.snmp.snmp2.SnmpPDU = New adventnet.snmp.snmp2.SnmpPDU
Dim objResultPDU As adventnet.snmp.snmp2.SnmpPDU = New adventnet.snmp.snmp2.SnmpPDU
Dim objOID As adventnet.snmp.snmp2.SnmpOID = New adventnet.snmp.snmp2.SnmpOID(OID)
Dim ipIPAddress As System.Net.IPAddress = System.Net.IPAddress.Parse(IPaddress)
Dim objUDPOpt As adventnet.snmp.snmp2.UDPProtocolOptions = New adventnet.snmp.snmp2.UDPProtocolOptions(ipIPAddress, Port)
objSession.Version = adventnet.snmp.snmp2.SnmpAPI.SNMP_VERSION_1
objSession.Open()
objPDU.DNSLookup = False
objPDU.ProtocolOptions = objUDPOpt
objPDU.Command = adventnet.snmp.snmp2.SnmpAPI.SET_REQ_MSG
objPDU.Community = Community
Dim myvar As adventnet.snmp.snmp2.SnmpVar = adventnet.snmp.snmp2.SnmpVar.CreateVariable(SetValue, dataType)
Dim varbind As adventnet.snmp.snmp2.SnmpVarBind = New adventnet.snmp.snmp2.SnmpVarBind(objOID, myvar)
objPDU.AddVariableBinding(varbind)
objResultPDU = objSession.SyncSend(objPDU)
objSession.Close()
objAPI.Close()
End Sub
Private Function snmpGet(ByVal IPaddress As String, ByVal Port As Integer, ByVal OID As String, ByVal Community As String) As adventnet.snmp.snmp2.SnmpPDU
Dim objSession As adventnet.snmp.snmp2.SnmpSession = Nothing
Dim objAPI As adventnet.snmp.snmp2.SnmpAPI = Nothing
Dim objPDU As adventnet.snmp.snmp2.SnmpPDU = Nothing
Dim objResultPDU As adventnet.snmp.snmp2.SnmpPDU = Nothing
Dim objOID As adventnet.snmp.snmp2.SnmpOID = Nothing
Dim objVar As adventnet.snmp.snmp2.SnmpVar = Nothing
Dim objVarBind As adventnet.snmp.snmp2.SnmpVarBind = Nothing
Dim objUDPOpt As adventnet.snmp.snmp2.UDPProtocolOptions = Nothing
Dim ipIPAddress As System.Net.IPAddress = Nothing
Dim strDebug As String = ""
Dim strInfo As String = ""
ipIPAddress = System.Net.IPAddress.Parse(IPaddress)
objAPI = New adventnet.snmp.snmp2.SnmpAPI
objSession = New adventnet.snmp.snmp2.SnmpSession(objAPI)
objPDU = New adventnet.snmp.snmp2.SnmpPDU
objResultPDU = New adventnet.snmp.snmp2.SnmpPDU
objUDPOpt = New adventnet.snmp.snmp2.UDPProtocolOptions(ipIPAddress, Port)
objOID = New adventnet.snmp.snmp2.SnmpOID(OID)
objSession.Version = adventnet.snmp.snmp2.SnmpAPI.SNMP_VERSION_1
objSession.Open()
objPDU.DNSLookup = False
objPDU.ProtocolOptions = objUDPOpt
objPDU.Command = adventnet.snmp.snmp2.SnmpAPI.GET_REQ_MSG
objPDU.Community = Community
objPDU.AddNull(objOID)
objResultPDU = objSession.SyncSend(objPDU)
objSession.Close()
objAPI.Close()
Return objResultPDU
End Function
in solution explorer, i see a folder name Service References but the folder is empty.