protected void Page_Load(object sender, EventArgs e) { SqlDataAdapter da = new SqlDataAdapter("SELECT PS, PS_IP_ADDRESS FROM m_police_station where STATE_CD=21 and PS_IP_ADDRESS is not Null and LANG_CD=99", con); DataSet ds = new DataSet(); da.Fill(ds); List<string> strIP = new List<string>(); foreach(DataRow row in ds.Tables[0].Rows) { strIP.Add(row["PS_IP_ADDRESS"].ToString()); } DataTable dt = ds.Tables[0]; dt.Columns.Add("Status", typeof(string)); foreach (DataRow dr in dt.Rows) { foreach (string s in strIP) { Ping p = new Ping(); PingReply r; // String str = "10.0.0.0"; r = p.Send(s); Response.Buffer = false; if (r.Status == IPStatus.Success) { dr["Status"] = "Y"; // Response.Write("Success \n"); } else { dr["Status"] = "N"; // Response.Write("fail"); } } Grid_Online_offline.DataSource = dt; Grid_Online_offline.DataBind(); } }
if (r.Status == IPStatus.Success) { dr["Status"] = "Y"; // Response.Write("Success \n"); } else { dr["Status"] = "N"; // Response.Write("fail"); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)