When we want to approach a file with delimiters as a database, we need to obtain a datatable from the Text Field Parser and put it in the Database Addon.

Since variables are only of the type 'String', we cannot use them for transfer, we have to use the functions in one line.



dim csvFile, dt


output = ""

csvFile = "#SCRIPTPATH#\99 TBT Example.csv"


' DBConnectWithDataTable uses a variable with type DataTable,

' while TFPGetDataTable returns a DataTable.

' Up to version 3.9,  variables are always of the type string (with internal conversion to numbers),

' The functions had to be integrated in one line to use the Datatable type:

' Status = DBConnectWithDataTable("TestCSV", TFPGetDataTable(csvFile, true, "")) 

' Since v3.9, variables can now contain objects as well so this will work also:

dt = TFPGetDataTable(csvFile, true, "")

Status = DBConnectWithDataTable(dt)


' Now convert the datatable to text and format the alignment

Output = DBToText("TestCSV", true)

Output = Tab2Spaces(output, DBGetColumnSize())

Created with the Personal Edition of HelpNDoc: Write eBooks for the Kindle