Solved

Do DNS/NetBIOS resolution using VBA

Posted on 2013-10-24
2
762 Views
Last Modified: 2013-10-24
Using this MS code as a base I'm able to build


Public Function TestPing()

Dim SQL As String
Dim DB As DAO.Database
Dim RS As DAO.Recordset
Dim I As Long


Dim hostname$, HostLen&
HostLen& = 256
hostname$ = Space$(HostLen&)


Dim Reply As ICMP_ECHO_REPLY
Dim lngSuccess As Long
Dim strIPAddress As String
   
I = 1
   'Get the sockets ready.
If SocketsInitialize() = True Then
      
    
    SQL = "SELECT ServerName, IP_Address, Ping_Status " & _
        "FROM Server_List " 
        
    Set DB = CurrentDb()
    Set RS = DB.OpenRecordset(SQL)
    
    If RS.EOF = False Then
        RS.MoveFirst
        Do Until RS.EOF = True
            strIPAddress = RS!IP_Address
            
            lngSuccess = ping(strIPAddress, Reply)
            With RS
                .Edit
                !Ping_Status = EvaluatePingResponse(lngSuccess)
                .Update
            End With
            
            Debug.Print I & ": " & "Address to Ping: " & strIPAddress & ": " & EvaluatePingResponse(lngSuccess)
            I = I + 1
            RS.MoveNext
        Loop
    End If
    
    RS.Close

    Set RS = Nothing
    Set DB = Nothing
      
    'Clean up the sockets.
    SocketsCleanup
      
Else
   
   'Winsock error failure, initializing the sockets.
   Debug.Print WINSOCK_ERROR
   
End If

End Function

Open in new window


So now what I want to do is verify the name that is currently attached to that IP address. So I am looking at the code linked at the bottom of the first set of code. But from what I can tell that only gets the current machine, not the name of a machine from the IP address. I want to build my code so that I close the first recordset and then process something like this:

   
    SQL = "SELECT ServerName, IP_Address, Ping_Status, Ping_ServerName " & _
        "FROM Server_List " & _
        "WHERE Server_List.Ping_Status = 'Success!'"
        
    Set RS = DB.OpenRecordset(SQL)
    
    If RS.EOF = False Then
        RS.MoveFirst
        Do Until RS.EOF = True
        
       IPAddr = RSIP_Address
--------------------------------------------------------------------
       'Get remote name from the IP address function  here.
        MachName = blah
--------------------------------------------------------------------
         With RS
                .Edit
                !Ping_ServerName = MachName 
                .Update
           End With
           RS.MoveNext
        Loop
    End If

Open in new window


The list I'm starting with includes IP addresses that were re-used on other servers. So I want to verify what the current machine is so I can then see if I have to dig into them.

Thanks.
0
Comment
Question by:Jim P.
2 Comments
 
LVL 35

Accepted Solution

by:
Kimputer earned 500 total points
Comment Utility
Use the code described here: http://access.mvps.org/access/api/api0067.htm
0
 
LVL 38

Author Closing Comment

by:Jim P.
Comment Utility
That worked. Just couldn't find a good google for it.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now