ServiceController[] services = ServiceController.GetServices(); { dataGridView1.DataSource = services ; } string conn = "Data Source=HostName;Initial Catalog=MSNETDB;Integrated Security=True;Pooling=False"; SqlConnection mycon = new SqlConnection(conn); mycon.Open(); foreach (DataGridViewRow row in dataGridView1.Rows) { string Displayname = row.Cells[3].Value.ToString(); string ServiceName = row.Cells[4].Value.ToString(); string Status = row.Cells[5].Value.ToString(); string ServiceType = row.Cells[6].Value.ToString(); SqlCommand com = new SqlCommand(conn, mycon); com .CommandText = "insert into SystemServiceInfo(DisplayName,ServiceName,Status,ServiceType)values('" + Displayname + "','" + ServiceName + "','" + Status + "','" + ServiceType + "')"; com.ExecuteNonQuery(); com.Parameters.Clear(); com.Dispose(); } mycon.Close(); mycon.Dispose();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)