# Visual Basic > Visual Basic .NET >  [RESOLVED] Data from Database export to a txt.file

## zubenubie

Good day,

I would like to import data from a database in a txt file. but i am struggling to get it in the wanted format.
I import the data via the following code:



```
 Using sw As StreamWriter = New StreamWriter("D:\Test.txt")
            Using reader As SqlDataReader = cmd.ExecuteReader()
                Dim values(reader.FieldCount - 1) As Object

                While reader.Read
                    reader.GetValues(values)

                    sw.WriteLine(String.Join(vbTab, values))
                End While
            End Using
        End Using
```

Below a picture how i get my data:


And here a picture how i want it ti be:


Also the latitude and longitude format are comma decimal formatted this is necessary for the calculations, but for the txt file it needs to be a decimal dot, any tips how to this?

Thanks in advance for the help

----------


## jmcilhinney

Theer are a number of things that need to be done to go form what you have to what you want. You should be addressing each one separately and implementing them step by step, then asking us about a specific step if and when you encounter an actual issue. It appears that you haven't even made an effort to identify the individual parts. For a start, your code has a single call to WriteLine and uses TAB delimiters when your desired output clearly requires multiple lines per record. How about you address that first, then consider what the next step might be?

This is how software development works. You don't treat it as one problem, throw your hands up and ask someone else to do it for you. You break it down into the smallest possible parts and then address each part individually. If you have an issue with a specific part then you can ask a very specific question about that part. Once that's addressed, you go onto the next part and, if you encounter another issue, you ask a completely separate question about that. Divide and conquer. because each individual part is smaller and simpler, there's far more chance of being able to handle it yourself and for more chance of getting help when asking a specific question.

----------


## zubenubie

You are right, but after a good night sleep and a good cup off coffee i got it sorted, i had all kinds of snippets, now i got it sorted

----------

