4 Replies - 339 Views - Last Post: 08 February 2012 - 04:13 PM Rate Topic: -----

Topic Sponsor:

#1 MBailey24  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 28-January 12

SQLCommand Insert Netstat results

Posted 08 February 2012 - 09:04 AM


I have a VB.net script that runs a simulation on several machines within the domain. During this simulation, a login is initiated to an application via a web portal. After the login, the connection to a specific Citrix server(whichever is least busy) is established. At this point, I want to run a Netstat -r | find (IP Range of server farm) in command line. From what I have deduced, I probably won't be able to do what I want from the command line and everything will have to be with in the VB.net module using System.Net.NetworkInformation. I am a Citrix Administrator with a decent level of .net experience but I am having trouble with this. Any advice would be greatly appreciated.

Is This A Good Question/Topic? 0
  • +

Replies To: SQLCommand Insert Netstat results

#2 MBailey24  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 28-January 12

Re: SQLCommand Insert Netstat results

Posted 08 February 2012 - 02:49 PM

How do I write this code to a text file?

 Dim properties As IPGlobalProperties = IPGlobalProperties.GetIPGlobalProperties()
                Dim connections As TcpConnectionInformation() = properties.GetActiveTcpConnections()

                Dim t As TcpConnectionInformation
                For Each t In connections
                    Console.Write("Local endpoint: {0} ", t.LocalEndPoint.Address)
                    Console.Write("Remote endpoint: {0} ", t.RemoteEndPoint.Address)
                    Console.WriteLine("{0}", t.State)
                Next t


Was This Post Helpful? 0
  • +
  • -

#3 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 960
  • View blog
  • Posts: 3,354
  • Joined: 25-September 09

Re: SQLCommand Insert Netstat results

Posted 08 February 2012 - 03:02 PM

Instead of Console.Write you could use the System.IO.StreamWriter to write your data to a file.

I would build a Formatted String and just pass that into the writer.
Was This Post Helpful? 0
  • +
  • -

#4 MBailey24  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 28-January 12

Re: SQLCommand Insert Netstat results

Posted 08 February 2012 - 04:09 PM

View PostCharlieMay, on 08 February 2012 - 03:02 PM, said:

Instead of Console.Write you could use the System.IO.StreamWriter to write your data to a file.

I would build a Formatted String and just pass that into the writer.

Ok. Once I accomplish that, how do I insert the data in the text file into a SQL table?
Was This Post Helpful? 0
  • +
  • -

#5 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 960
  • View blog
  • Posts: 3,354
  • Joined: 25-September 09

Re: SQLCommand Insert Netstat results

Posted 08 February 2012 - 04:13 PM

Well, you would need to decide on a database type, and then I suggest reading the tutorial from the tutorials section here on D.I.C. Oledb for access, SQL for MS Sql. This will give you a good start.

But... The information is there, it's just a matter of sending it to where you want to store it. Once you establish that, a quick INSERT into your database is only 5 or six lines of code.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1