Try the the following code after loading the records in datagridview.
string str="";
for(int i=0;i<dataGridView1.RowCount;i++)
{
for (int j = 0; j < dataGridView1.ColumnCount; j++)
{
str += dataGridView1.Rows[i].Cells[j].Value.ToString() +";";
}
str += Environment.NewLine;
}
System.IO.File.AppendAllText(@"d:\anand.txt", str);
Thanks,
Anand. G