Tuesday, February 12, 2013

Create a flat file utility

This is my first post WRT C# and/OR VB.NET. At work I was given a task to create a utility that will generate a flat file where we can pass database servername, databasename, procedurename (no parameterized procs and which spit out multiple resultsets), Output file path, output file name, fileextension, column delimiter (comma,tab,colon,semicolon,pipe), header required (Yes/no/y/n), append timestamp to filename, row terminator(unix/windows). I came up with a solution to create a console application in both c# and VB.NET.

Here is the VB.NET code. This works only with SQL Server connections

Example:

CreateFlatFile.exe Server DB Procedure FilePath FileName .csv colon y y unix. Syntax is same for C# as well.

VB code
Csharp code