I've figured something out. :) BTW thanks again for your reply
using (MySqlConnection con = new MySqlConnection("server=localhost;port=3306; user id=root; password=;database=test;Charset=utf8;"))
{
con.Open();
//Count no of distinct visitors based on IP address
DataSet ds = new DataSet();
MySqlDataAdapter tot = new MySqlDataAdapter("SELECT distinct(count(ip_addr)) FROM ip_table", con);
tot.Fill(ds, "ip_addr");
lblcount.Text = "<span class='badge badge-info'><span class='glyphicon glyphicon-user'></span> = " + ds.Tables["ip_addr"].Rows[0][0].ToString() + "</span>";
//Get client ip address
string ipaddress;
ipaddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (ipaddress == "" || ipaddress == null)
{
ipaddress = Request.ServerVariables["REMOTE_ADDR"];
}
//Save ip address or increment hitcount
string ip_date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
//MySqlCommand cmd = new MySqlCommand("insert into ip_table (ip_addr,ip_date) values (@ip_addr,@ip_date) ON DUPLICATE KEY UPDATE ip_hitcount = ip_hitcount + 1 , ip_date = '" + ip_date + "'", con);
MySqlCommand cmd = new MySqlCommand("INSERT INTO ip_table (ip_addr,ip_date) VALUES (@ip_addr,@ip_date) ON DUPLICATE KEY UPDATE ip_hitcount = ip_hitcount + 1 , ip_date = VALUES(ip_date)", con);
cmd.Parameters.AddWithValue("@ip_addr", ipaddress);
cmd.Parameters.AddWithValue("@ip_date", ip_date);
cmd.ExecuteNonQuery();
}