Hi, I am working with VB6 to make a program that makes a SQL SELECT to a generic table in a database and then outputs the information brought by the SELECT to an excel csv file.
So far I was able to output all the rows returned by the SELECT using a record set, but I cannot get column names.
The code is below:
OBS: The record set is the tabRefRecord variable and at this point in the code I have already made query on the database.
As you can see I am outputing all the rows in the table except the column names.
Could you tell me how can I get the column names from the record set?
Thanks,
Komyg
PS: I'm also outputing the data to a data grid, is it possible to get the column names from the data grid?
So far I was able to output all the rows returned by the SELECT using a record set, but I cannot get column names.
The code is below:
OBS: The record set is the tabRefRecord variable and at this point in the code I have already made query on the database.
Code:
Private Sub csvCreator()
Dim csvStr As String
Dim str As String
Dim i As Integer
Open "C:\Documents and Settings\Administrator\Desktop\teste.txt" For Output As #1
If Not tabRefRecord.RecordCount = 0 Then
tabRefRecord.MoveFirst
End If
While Not tabRefRecord.EOF
str = ""
For i = 0 To tabRefRecord.Fields.Count - 1
str = str & tabRefRecord.Fields(i) & ";"
Next i
Print #1, str
tabRefRecord.MoveNext
Wend
Close #1
End Sub
As you can see I am outputing all the rows in the table except the column names.
Could you tell me how can I get the column names from the record set?
Thanks,
Komyg
PS: I'm also outputing the data to a data grid, is it possible to get the column names from the data grid?