Link to home
Create AccountLog in
Avatar of HLRosenberger
HLRosenbergerFlag for United States of America

asked on

what is the easiest way to write out a CSV file?

what is the easiest way to write out a CSV file?
Avatar of EYoung
Flag of United States of America image

The easiest and quickest way is to use SQL Server's dts utility.  That assumes the data is stored in SQL.  Once you do that, you can run the dts package from within a VB program if this will be a reoccurring job.
Avatar of HLRosenberger


Maybe I did not state my question correctly - I just want to write out a flat file - comma delimited.   A flat file - I should have not stated CSV.
Avatar of Den_HBR

Dim _Writer As New System.IO.StreamWriter("c:\test.txt", false, System.Text.Encoding.Default)
                _Writer.Write("this is your tekst)
Avatar of Den_HBR

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Give some more details. Write out a flat, comma delimited file from what? From a string, array, listof string, database .......?? The possibilities can be endless.
Avatar of Fernando Soto
Hi HLRosenberger;

You can do the following to get what you need.

1.  Create a String array. For example Dim strArray(5) As String
2. Loop through the list of values to be placed on one line and assign them to the correct array location
3. If one of the fields is to be empty assign it String.Empty
4. When all the fields have been assigned write it out to the System.IO.StreamWriter, assuming the
    name of the  StreamWriter is sw the following will write a CSV line to the file.
    sw.WriteLine(String.Join(",", strArray))
5. Continue looping until all lines have been written out to the file and close the file.

you must disable split tunnel otherwise, the remote users will use their internet as well as being connected to your network.   Sorry, it has been a while but I rollout the VPN client to 100 users 2 years ago.   In the VPN client builder, you have the option...