i have a table in sqlserver having following fields
name,age,dateofborth,phonenumber
now i want to convert it into text file
how can i do this,
it is very urgent
plz provide a code for the same
i am using vs2005
Ascii text file
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Nipun TomarRank #90 · 23K reputationPosted Jan 17, 2007, 8:44 AM EST
If you want to do it through code, you can try the following:
FileStream fileStream = File.Open(@"C:\Temp\NewText.txt", FileMode.Create, FileAccess.Write, FileShare.None);
StreamWriter streamWriter = new StreamWriter(fileStream);
foreach (DataRow dr in dataSet.Tables[0]) //datSet having your required records
{
//change /t to required formatting you want
streamWriter.WriteLine(dr["ColumnName1"].ToString() + "/t" + dr["ColumnName2"].ToString());
}
streamWriter.Close();
fileStream.Close();
Hope this will help..
Himanshu5 reputationPosted Jan 18, 2007, 12:37 AM EST