I am running this code, but when I hit the foreach loop it never writes any data just closes the connection and moves on...What do I need to alter?'
SqlCommand cmd = new SqlCommand(QS, con); con.Open(); SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds); //logfile is declared earlier in the code and exists StreamWriter sw = new StreamWriter(logfile); //This is where it hits but never writes anything foreach (DataRow in ds.Tables[0].Rows { //Do stuff }