using (SqlConnection cs = new SqlConnection( @"Data Source=100-NUprod-P-001.acds.net;Initial Catalog=Nuprod;Persist Security Info=True;User ID=Nuprod;Password=MyPa$$word")) { cs.Open(); using (SqlDataAdapter da = new SqlDataAdapter(@"Select top 25 stationipaddress From machines", cs)) { 3 Use DataAdapter to fill DataTable DataTable t = new DataTable(); da.Fill(t); 4 Render data onto the screen dataGridView1.DataSource = t; // <-- From your designer } Thread.Sleep(2000); foreach (DataGridViewRow row in this.dataGridView1.Rows) { try { foreach (DataGridViewCell cell in row.Cells) { if (!cell.Size.IsEmpty) { MessageBox.Show(cell.Value.ToString()); ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = "net.exe"; startInfo.Arguments = @"use \\" + cell.Value.ToString() + "\\c$" + " " + "Password /user:admin"; startInfo.UseShellExecute = false; startInfo.RedirectStandardOutput = true; startInfo.RedirectStandardInput = true; startInfo.CreateNoWindow = true; Process.Start(startInfo); Thread.Sleep(1000); } } } catch (Exception) { MessageBox.Show("First Query Complete"); foreach (DataGridViewRow row1 in this.dataGridView1.Rows) { try { foreach (DataGridViewCell cell in row1.Cells) { if (!cell.Size.IsEmpty) { int timeout = 5000; Process process = new Process(); process.StartInfo.FileName = "xcopy"; process.StartInfo.Arguments = textBox1.Text + " " + @"\\" + cell.Value.ToString() + @"\" + textBox2.Text + @"/C/Y/E/Q/F"; process.StartInfo.UseShellExecute = false; process.StartInfo.RedirectStandardOutput = true; process.StartInfo.RedirectStandardInput = true; process.StartInfo.CreateNoWindow = true; process.Start(); process.WaitForExit(timeout); } } } catch (Exception) { var compiler = new Process(); compiler.StartInfo.FileName = "net.exe"; compiler.StartInfo.Arguments = "use * /delete /Y"; compiler.StartInfo.UseShellExecute = true; compiler.StartInfo.RedirectStandardOutput = false; compiler.Start(); Thread.Sleep(1000); MessageBox.Show("Part 1 Copy Done"); cs.Close(); } } } }
using (SqlConnection cs = new SqlConnection( @"Data Source=100-NUprod-P-001.acds.net;Initial Catalog=Nuprod;Persist Security Info=True;User ID=Nuprod;Password=MyPa$$word")) { cs.Open(); using (SqlDataAdapter da = new SqlDataAdapter(@"Select top 25 stationipaddress From machines", cs)) { //3 //Use DataAdapter to fill DataTable DataTable t = new DataTable(); da.Fill(t); //4 //Render data onto the screen GridView1.DataSource = t; // <-- From your designer } Thread.Sleep(2000); foreach (GridViewRow row in this.GridView1.Rows) { try { foreach (GridViewCell cell in row.Cells) { if (!cell.Size.IsEmpty) { //MessageBox.Show(cell.Value.ToString()); ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = "net.exe"; startInfo.Arguments = @"use \\" + cell.Value.ToString() + "\\c$" + " " + "Password /user:admin"; startInfo.UseShellExecute = false; startInfo.RedirectStandardOutput = true; startInfo.RedirectStandardInput = true; startInfo.CreateNoWindow = true; Process.Start(startInfo); Thread.Sleep(1000); } } } catch (Exception) { //MessageBox.Show("First Query Complete"); foreach (GridViewRow row1 in this.GridView1.Rows) { try { foreach (GridViewCell cell in row1.Cells) { if (!cell.Size.IsEmpty) { int timeout = 5000; Process process = new Process(); process.StartInfo.FileName = "xcopy"; process.StartInfo.Arguments = textBox1.Text + " " + @"\\" + cell.Value.ToString() + @"\" + textBox2.Text + @"/C/Y/E/Q/F"; process.StartInfo.UseShellExecute = false; process.StartInfo.RedirectStandardOutput = true; process.StartInfo.RedirectStandardInput = true; process.StartInfo.CreateNoWindow = true; process.Start(); process.WaitForExit(timeout); } } } catch (Exception) { var compiler = new Process(); compiler.StartInfo.FileName = "net.exe"; compiler.StartInfo.Arguments = "use * /delete /Y"; compiler.StartInfo.UseShellExecute = true; compiler.StartInfo.RedirectStandardOutput = false; compiler.Start(); Thread.Sleep(1000); //MessageBox.Show("Part 1 Copy Done"); cs.Close(); } } } }
System.Windows.Forms
System.Web.UI.WebControls.GridView
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)