I get the error that "Argument"1": cannot convert from
'string' to 'System.Data.DataRow' at the foreach loop to add rows to the
DataTable...any ideas how to fix this?
Paul
==================================================
private void button1_Click(object sender, System.EventArgs e)
{
richTextBox1.Text=null; //Clear
the RichTextBox
WebRequest req =
WebRequest.Create("http://www.sec.gov/Archives/edgar/daily-index/" +
"company." + "20041222" + ".idx"); // Create the Request object
WebResponse response = req.GetResponse(); //Create
the Response object
Stream stream = response.GetResponseStream(); //Create a
Stream
StreamReader sr = new StreamReader(stream); //Open the file in
a stream reader
DataSet result = new DataSet(); //The DataSet
to Return
//StreamReader sr = new StreamReader("c:\\test.txt"); //Read From A
File instead of a webreques
//---------------------------------------------------------------------------------------------------
string AllData1 = sr.ReadToEnd(); //Read the rest of
the data in the file.
result.Tables.Add("MyNewTable"); //Add DataTable to hold
the DataSet
result.Tables["MyNewTable"].Columns.Add("Data"); //Add a single
column
string[] rows = AllData1.Split("\r\n".ToCharArray()); //Split off each
row at the Carriage Return/Line Feed
foreach(string r in rows)
{
result.Tables["MyNewTable"].Rows.Add(r); //Add the row to the
DataTable/DataSet
}
for (int i = 1; i <= 8; i++)
{
result.Tables["MyNewTable"].Rows.RemoveAt(0); //Remove first 8 rows
from the DataTable/DataSet
}
//---------------------------------------------------------------------------------------------------
dataGrid1.SetDataBinding(result, "MyNewTable"); //Binds DataGrid to
DataSet,displaying datatable.
}