Generate a report in .txt file datasource is SQl server in vb.net

Dear Experts,
In my vb.net application , I need to generate a .txt file from sql server as datasource,This .txt file is a report that contains sub reports,my question is what is the best possible way to generate this .txt file either export from crystal report or direct formatting th .txt file.
I need vb.net code as an example as i am not so proficient in programming,pls find the attached file ......
sachin_upadhyayAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dshrivallabhCommented:
If its a formatted text file ..then it must be written manually by you using code and iterating thru the datasorce.

StringBuilder sb = new Stringbuilder();

Foreach row in datasource.rows
   format the row as you like in the text file
Next

using (StreamWriter outfile =
            new StreamWriter(path + @"\filename.txt"))
        {
            outfile.Write(sb.ToString());
        }
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Tommy11bCommented:
By subreport do you mean there where be child records that doesnt fit the overall record structure of the text file? Is an XML file allowable? Simple to fill a dataset from Sql and call a method to export to an xml file, even with nested child records.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.