I've been trying to pull the individual rows off an SQL server and I've been looking for a way to be able call each row individually to use a method to be able to buffer the string to the specified determined format to a text file. Here is the writing using the textwriter portion that calls the writing of the rows:

using (TextWriter tw = File.CreateText("c:/Extracts/Extractions.txt"))
{ //Starts using
//Loop through DataTable appending columns to the StringBuilder
for (int i = ZERO; i < dataTable.Columns.Count; i++)
{ //Starts Appending loop
while (executionReader.Read())
{ //Start while
if (executionReader.Read() != false)
{ //Start if
tw.Write(dataTable.Columns[i].ColumnName + " | ");
} //End if
{ //Start else
tw.Write(dataTable.Columns[i].Ordinal - 3 + "\n");
} //End else
} //End while
} //Ends for loop
//Iterate through the fields
while (executionReader.Read())
{ //Starts reading
for (int a = dataTable.Columns.Count; a >= ZERO; a--)
{ //Starts for
if (a != ZERO)
{ //Starts if
} //Ends if
else if (a == ZERO)
{ //Starts else-if
tw.Write(dataTable.Rows.ToString() + "\n");
} //Ends else-if
{ //Starts else
throw new Exception();
} //Ends else
} //Ends for
} //Ends while
//Dispose of string in TextWriter
//Close TextWriter
} //Ends using (TextWriter)

Could anyone help on a way to pull each individual row so I can use this method as a buffer:

public string string_buffer(string str, int length, string buffer)
{ //Starts string_buffer()
{ //Starts try
while (str.Length < length)
{ //Starts while
str += buffer;
} //Ends while
} //Ends try
catch (Exception ex)
{ //Starts catch
Console.WriteLine("Error: " + ex.StackTrace);
} //Ends catch
return str;
} //Ends string_buffer()