aar0n
Member
I know this should be basic looping stuff but I'm hitting a mental snag and could use another set of eyes at this point.
The task is fairly simple. I have built a windows app. which streams database tables into individual text files - one DB table per file. The user uses an XML file to configure the parameters which include TableName and FileName. All works fine until I attempt to extend to allow for multiple tables -> multiple files. I need to get the looping to hit the CreateFile method ONCE PER DATATABLE. Currently I am ending up with the same data table for both files.
In the below example, the user wants to convert 2 tables (company and people) into files...
INPUT:
I'll provide more info if needed, but I could use a few pointers here. Thanks in advance for any help I might get on here. I'm thinking that the solution is basic looping and I'm just missing it.
-Aaron
The task is fairly simple. I have built a windows app. which streams database tables into individual text files - one DB table per file. The user uses an XML file to configure the parameters which include TableName and FileName. All works fine until I attempt to extend to allow for multiple tables -> multiple files. I need to get the looping to hit the CreateFile method ONCE PER DATATABLE. Currently I am ending up with the same data table for both files.
In the below example, the user wants to convert 2 tables (company and people) into files...
INPUT:
VB.NET:
<Provider>SQLServer</Provider>
<TableName>company,people</TableName>
<Headers>YES</Headers>
<Target>C:\Program Files\ODBCExport\Test\</Target>
<FileName>company.txt,people.txt</FileName>
<Delimeter>|</Delimeter>
VB.NET:
Try
Dim objDAL As New DAL
Dim files As String() = strFName.Split(New Char() {","})
Dim tables As String() = strTable.Split(New Char() {","})
Dim t As Integer = 0
Dim f As Integer = 0
For Each mytable As String In allables
table = tables(t)
Dim dt As DataTable = objDAL.GetDataTable(strProvider, strDBSource, table) 'Gets 1 table
t += 1
For Each myFile As String In files
Dim strfullpath = strTarget + myFile
CreateTextFile(dt, strfullpath, strDelim) 'should create a file based on the above table
Next
Next
Catch oops As Exception
WriteToErrorLog(oops.Message.ToString)
lblMessage.Visible = True
lblMessage.Text = "Database Connection or File Path Error. See error file for details."
End Try
I'll provide more info if needed, but I could use a few pointers here. Thanks in advance for any help I might get on here. I'm thinking that the solution is basic looping and I'm just missing it.
-Aaron
Last edited: