Massive edit as I've had a fiddle with the code:
So I need to print out a datatable to a text file using vb.net.
This is what I've got so far:
Public Shared Sub WriteCode()
Dim index As String = "\\ndrive\by006946\My Documents\Business Programming\Web Server Root\index.html"
Dim Introduction As String = "<html><b>Welcome! Here are your subscribed classes:</b></html>"
Dim selecteduser As String = LoginPage.UserNameBox.Text
If System.IO.File.Exists(index) = True Then
Dim objwriter As New System.IO.StreamWriter(index)
Dim courses As New DataSet
courses = GetUserCourses(selecteduser)
Dim subclasses As DataTable = New DataTable("Courses")
subclasses.Columns.Add("Course Name")
Dim count As Integer
count = CountRecords() - 1
For i As Integer = 0 To count
subclasses.Rows.Add(courses.Tables(0).Rows(i).Item(0)) 'Displays all the users subscribed courses
Next
objwriter.Write(subclasses.)
objwriter.Close()
End If
End Sub
However so far all it's printing out is "Courses". I need it to print out all the rows as well. Any idea?
I think a for..each loop will done what you wanted to do.
generate , tags inside the for..each loop.