Hi, this is my problem: i've some data in an access database, i collect this data from the table and when i try to record the data in the text file, with the fields separated with a "!", the registration fails, better, doesn't register all the datas that are in the table.
This is the code:
Now, i did not understand why also if the table has two rows, in the text file i register only one.
Seems that the problem is that the saving of rows in the db access is not yet completed, because when i bypass in debug mode the code, perche' quando vado in debug, sometime the loop say me that are present two rows and not one.
Help me, because i'vent no idea on the solution.
Thanx to all.
This is the code:
VB.NET:
Dim tw As TextWriter = File.AppendText(Application.StartupPath & "\DStampa.csv")
Dim objDataTable As DataTable
Dim TotaleDatiStampa As String = ""
objDataTable = objData.QueryDatabase("SELECT * FROM SStato ORDER BY Cam, Dal")
If objDataTable.Rows.Count <> 0 Then
TotaleDatiStampa = ""
For i = 0 To objDataTable.Rows.Count - 1
If Not IsDBNull(objDataTable.Rows(i).Item("Cam")) Then TotaleDatiStampa = objDataTable.Rows(i).Item("Cam").ToString & "!" Else TotaleDatiStampa = "!"
If Not IsDBNull(objDataTable.Rows(i).Item("Stato")) Then TotaleDatiStampa = TotaleDatiStampa & objDataTable.Rows(i).Item("Stato").ToString & "!" Else TotaleDatiStampa = TotaleDatiStampa & "!"
If Not IsDBNull(objDataTable.Rows(i).Item("Dal")) Then TotaleDatiStampa = TotaleDatiStampa & CDate(objDataTable.Rows(i).Item("Dal")).ToShortDateString & "!" Else TotaleDatiStampa = TotaleDatiStampa & "!"
If Not IsDBNull(objDataTable.Rows(i).Item("Al")) Then TotaleDatiStampa = TotaleDatiStampa & CDate(objDataTable.Rows(i).Item("Al")).ToShortDateString & "!" Else TotaleDatiStampa = TotaleDatiStampa & "!"
If Not IsDBNull(objDataTable.Rows(i).Item("MieNote")) Then TotaleDatiStampa = TotaleDatiStampa & objDataTable.Rows(i).Item("MieNote").ToString & "!" Else TotaleDatiStampa = TotaleDatiStampa & "!"
If i < objDataTable.Rows.Count - 1 Then i = i + 1
Next
End If
tw.WriteLine(TotaleDatiStampa)
tw.Close()
objDataTable = Nothing
Now, i did not understand why also if the table has two rows, in the text file i register only one.
Seems that the problem is that the saving of rows in the db access is not yet completed, because when i bypass in debug mode the code, perche' quando vado in debug, sometime the loop say me that are present two rows and not one.
Help me, because i'vent no idea on the solution.
Thanx to all.