Thursday, November 17, 2011

PHP CODE to Find MAC Address and HOST Name

Using following code will help you find MAC Address and Host Name of Selected IP.  To execute following code you need to change the security permission of cmd.exe
Go to \Windows\System32\cmd.exe right click on it and select properties. Select user Internet Guest Accounts/IUSER….
Then add the full control. Follow the picture.
$hostname = gethostbyaddr(trim(''));
$ip = '';

SYSTEM(`ping $ip -n 1 && arp -a`);
$output = `arp $ip -a`;
$line = $output;

$pos = strpos("$line","$ip");

$mac = str_replace("$ip","", $line);
$mac1 = str_replace("dynamic","", $mac);
$mac2 = trim(substr($mac1,86));

    if ($ip == $hostname)
            $host = '';  
            $host = $hostname;  
echo 'Host Name   :    ', $host;
echo '<BR>';
echo 'Mac Address :    ', $mac2;



Using following code you can ping host name/ IP Address.  To execute following code you need to change the security permission of cmd.exe
Go to \Windows\System32\cmd.exe right click on it and select properties. Select user Internet Guest Accounts/IUSER….
Then add the full control. Follow the picture.

   $host   = "";
   echo("Ping Output:<br>");
      echo '<pre>';          
        system("ping -n 3 $host");
      echo '</pre>';

Note: you can ping IP address/hostname using this script.

Wednesday, November 16, 2011

VB.NET Send Mail Code

Following coding used to send mail from VB.NET using GMAIL Accounts.

  Imports System.Net.Mail

  Dim SmtpServer As New SmtpClient()
        Dim mail As New MailMessage()
        Dim sMsg1, sFooter As String
        Dim sTo, sMailuser, sPassword As String
            sMailuser = ""
            sPassword = "Account Password" 'Password of mail.
sMsg1 = " This is test mail from GMAIL account. "
            sFooter = "<BR><BR>This is footer."
            sTo = ""

            SmtpServer.Port = 587
            SmtpServer.Host = ""
            SmtpServer.EnableSsl = True
SmtpServer.Credentials = New  _
            Net.NetworkCredential(sMailuser, sPassword)

            mail = New MailMessage()
            mail.From = New MailAddress(sMailuser)   'From Address
            mail.To.Add(sTo)  ' To Address
            mail.Subject = "Subject of Mail " 'Subject of Mail.
            mail.Body = sMsg1 + sFooter
            mail.IsBodyHtml = True
            MsgBox("Mail Sent.")
        Catch ex As Exception
        End Try

VB.NET MySQL (Insert Picture in Blob Field)

Following coding will help you to insert picture from VB.NET to MySql BLOB field. Coding is very simple.

First you need to install MyODBC for your windows. Installation is very simple. You can download MyODBC from following link:

Create table statement for MySQL.

CREATE TABLE `picture` (
  `ID` int(32) unsigned NOT NULL auto_increment,
  `Picture` longblob,
  `EmployeeID` varchar(10) default NULL,
  KEY `ID_2`(`ID`)


Imports System.IO        'Write this coding before Class declaretion.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

  Dim cmd As New Odbc.OdbcCommand
  Dim SQL As String
  Dim rawData() As Byte
  Dim fs As FileStream
  Dim sPath As String
  Dim connectionString As String = "Driver={MySQL};" & _
        "Server=server_name;" & _
        "Database=DSN_Name;" & _
        "Uid=root;" & _
        "Pwd=root;" & _

  Dim conn As New Odbc.OdbcConnection(connectionString)

  sPath = txtPicturePath.Text

  fs = New FileStream(sPath, FileMode.Open, FileAccess.Read)
  rawData = New Byte(fs.Length) {}
  fs.Read(rawData, 0, fs.Length)
SQL = "INSERT INTO Picture(EmployeeID, Picture) VALUES('" & TxtID.Text & "', ?)"
  cmd.Connection = conn
  cmd.CommandText = SQL
  cmd.Parameters.Add("@bin_data", rawData)

End Sub
If above code work please share the link.

Tuesday, November 15, 2011


Few days ago, my power, network, and volume icons disappeared from the tray area of Windows 7.  When I chose “Customize notification icons” and then “Turn system icons on or off”, the choices were grayed out like the image to the left.
I tried the Group Policy and registry solutions that I found online, but with no success.
Here’s how I finally fixed it:
  1. Run a Command Prompt as administrator, then “sfc /scannow
  2. Find the sfc log file at C:\Windows\Logs\CBS\CBS.log and search it for “cannot repair”.
I discovered that 6 .dll files from C:\Windows\system32 were messed up.  I found a nice explanation here as to how to extract the files from the Windows 7 installation DVD using 7-Zip, which I already like for other zipping and unzipping tasks.
Unfortunately, you can’t just copy the files into C:\Windows\system32.  Here’s what I had to do to replace the .dll files:
  1. Extract the files from the installation DVD into a local folder, such as c:\extracted-files
  2. Boot the installation DVD, choose to repair Windows, and get to a Command Prompt
  3. Use the command line to copy the .dll files from c:\extracted-files to c:\windows\system32
  4. Reboot
It will solve the problem of System icon.

VB.NET & MySql Connection (ADODB)

Some time when we search for VB.NET MYSQL Connection in internet we found lots of complicated solutions. I also face same problem. That’s why I would like to share my experience with you.  I hope it will also help for you.

You need to install MyODBC 2.5 or later version need to install. Check the MyODBC version in following link:

Or You can just extract the MyODBC zip file and copy the MYODBC.DLL into System32 folder.

Add References of ADODB (Project Add References).

  Dim con As New ADODB.Connection
        cst = "Driver={MySQL};" & _
        "Server=server_name;" & _
        "Database=Database_Name;" & _
        "Uid=userid;" & _
        "Pwd=password;" & _

     con.CursorLocation = ADODB.CursorLocationEnum.adUseClient
Sample data retrieve in Grid:
Dim iRow As Integer
Dim rs As New ADODB.Recordset
Dim qrystr As String

qrystr = "Select EmployeeID, Name From Employee Order by EmployeeID"

rs.Open(qrystr, con, ADODB.CursorTypeEnum.adOpenStatic,

If rs.RecordCount > 0 Then
   EmployeeGrid.RowCount = rs.RecordCount
   For iRow = 0 To rs.RecordCount - 1
EmployeeGrid.Item(0, iRow).Value = rs.Fields("EmployeeID").Value EmployeeGrid.Item(1, iRow).Value = rs.Fields("Name").Value
      EmployeeGrid.RowCount = 1
      EmployeeGrid.Item(0, 0).Value = ""
      EmployeeGrid.Item(1, 0).Value = ""
 End If