Hi all,
I am dealing with an application, developed in hta and Visual basic. All I was asked was to add the sorter functionality to the dynamically populated table (using the data obtained by the WMI connection made to a machine, to get the DNS records).
It is bassically just a html code that I need to run to get the sorter working, which call the jscript and CSS. Here is the code,
Code:
document.write "<div id = ""main""> <div id = ""demo""> <table cellspacing = ""1"" class = ""tablesorter"">"
document.write "<thead><tr><th>First Name</th><th>Age</th></tr>
</thead>"
document.write "<tbody><tr><td>Parker</td
><td>90</t
d></tr>"
document.write "<tr><td>arker</td><td>70<
/td></tr>"
document.write "<tr><td>rker</td><td>80</
td></tr>"
document.write "</tbody></table></div><br
>"Now coz I dont have much idea about the Visual basic, when I run this code as it is out side the function ConnectToDNSServer() (in the below code) it works fine but I try to put it inside it does not take the functionality from CSS and the jscript it is calling. Here is the code,
Code:
Sub ConnectToDNSServer()
Dim strDNSServer, inFile, i
strDNSserver = InputBox("Enter the DNS server to connect to : ", "DNS Server",,200,200)
document.write "<input type=button value=""Connect to Server"" Onclick='ConnectToDNSServe
r()'>"
document.write "<h2>Displaying : " & strDNSserver & "</h2>"
document.write "<hr color=#FF9933>"
document.write "<div id = ""main""> <div id = ""demo""> "
document.write "<table cellpadding=""0"" cellspacing=""4"" border=""1"" width=""600"" class = ""tablesorter"" >" document.write "<thead>"
document.write "<tr>"
document.write "<th>DNS NAME</th>"
document.write "<th>Type</th>"
document.write "<th>IP address</th>"
document.write "<th>Timestamp</th>"
document.write "</tr>"
document.write "</thead>"
Dim objDNS, objDNSServer, objRRs, objInst, cnt, recDetailscnt = 0
On Error Resume Next
Err.Clear
Set objDNS = GetObject("winMgmts:\\" & strDNSserver & "\root\MicrosoftDNS")
If Err.number <> 0 Then
MsgBox("Error connecting to DNS Server : " & strDNSserver)
LoadForm()
Else
Set objRRs = objDNS.ExecQuery("Select * from MicrosoftDNS_ResourceRecor
d " & _"WHERE ContainerName = 'uk.world.socgen'")
For each objInst in ObjRRs
recDetails = split(objInst.TextRepresen
tation)
document.write "<tbody><tr>"
document.write "<td>" & recDetails(0) & "</td>"
document.write "<td>" & recDetails(2) & "</td>"
document.write "<td>" & recDetails(3) & "</td>"
document.write "<td>" & objInst.Timestamp & "</td></tr></tbody>" & VbCrLf
cnt = cnt + 1
If cnt = 100 Then
document.write " </table></div>"Can any one think of a way out, so that the line,
Set objDNS = GetObject("winMgmts:\\" & strDNSserver & "\root\MicrosoftDNS")
above would work properly? If I run the test code outside the sub in the VB script it works fine. I am sure that it has to do with the functionality of the sub, I think it reloads the form/page as the test table appears when inserted just before the functions but I am not sure how to get it working inside the sub so that it keeps the functionality after when the form is reloaded?
It is realy very urgent for me to get this piece of code to work. I will appretiate if some one could quickly give me a tip on it.
Regards,
Sameer.