Dear sir
I'm Trying to import datfiles with filter based on datetimepicker & insert to ms access with dapper VB.NET
means there are 2 controls, namely DateTimePicker1 & DateTimePicker2
I use 2 control dateTimePicker because it states one period which is the start date and end date.
DateTimePicker1 => 18-Mar-24
DateTimePicker2 <= 19-Mar-24
Please Guide me
Thanks
Protected Sub ReadDat()
Dim fName As String = ""
OpenFileDialog1.InitialDirectory = "D:\TestFile"
OpenFileDialog1.Filter = "Dat files(*.Dat)|*.Dat"
OpenFileDialog1.RestoreDirectory = True
If (OpenFileDialog1.ShowDialog() = DialogResult.OK) Then
fName = OpenFileDialog1.FileName
End If
If File.Exists(fName) = True Then
Dim lines As String() = File.ReadAllLines(fName)
Dim datfiles As List(Of datfiles) = New List(Of datfiles)()
For i As Integer = 0 To lines.Length - 1
If Not String.IsNullOrEmpty(lines(i).Trim()) Then
Dim data As String() = lines(i).Trim().Split(CType(vbTab, Char()))
datfiles.Add(New datfiles() With {
.ID = data(0),
.DATE = data(1).ToString().Split(" "c)(0),
.TIME = data(1).ToString().Split(" "c)(1),
.FP = data(2),
.INOUT = If(data(3).ToString() = "0", "IN", "OUT"),
.OTHERS1 = data(4),
.OTHERS2 = data(5)
})
End If
Next
' Use the DataTable to populate the DataGridView.
BunifuDataGridView1.Visible = True
BunifuDataGridView1.DataSource = datfiles
BunifuDataGridView1.ReadOnly = True
Else
MsgBox("File Does Not Exist")
End If
End Sub
Sample
5010 2024-03-16 06:59:10 1 0 0 0
5014 2024-03-16 07:11:00 1 0 0 0
5014 2024-03-16 16:32:09 1 1 0 0
5010 2024-03-16 16:33:19 1 1 0 0
5010 2024-03-17 06:59:10 1 0 0 0
5014 2024-03-17 07:11:00 1 0 0 0
5014 2024-03-17 16:32:09 1 1 0 0
5010 2024-03-17 16:33:19 1 1 0 0
5010 2024-03-18 06:59:10 1 0 0 0
5014 2024-03-18 07:11:00 1 0 0 0
5014 2024-03-18 16:32:09 1 1 0 0
5010 2024-03-18 16:33:19 1 1 0 0
5010 2024-03-19 07:05:15 1 0 0 0
5014 2024-03-19 07:31:19 1 0 0 0
5014 2024-03-19 16:30:50 1 1 0 0
5010 2024-03-19 16:31:12 1 1 0 0
5010 2024-03-20 07:05:15 1 0 0 0
5014 2024-03-20 07:31:19 1 0 0 0
5014 2024-03-20 16:30:50 1 1 0 0
5010 2024-03-20 16:31:12 1 1 0 0
result from code
ID DATE TIME FP IN/OUT OTHERS1 OTHERS2
5010 16-Mar-24 06:59:10 1 IN 0 0
5014 16-Mar-24 07:11:00 1 IN 0 0
5014 16-Mar-24 16:32:09 1 OUT 0 0
5010 16-Mar-24 16:33:19 1 OUT 0 0
5010 17-Mar-24 06:59:10 1 IN 0 0
5014 17-Mar-24 07:11:00 1 IN 0 0
5014 17-Mar-24 16:32:09 1 OUT 0 0
5010 17-Mar-24 16:33:19 1 OUT 0 0
5010 18-Mar-24 06:59:10 1 IN 0 0
5014 18-Mar-24 07:11:00 1 IN 0 0
5014 18-Mar-24 16:32:09 1 OUT 0 0
5010 18-Mar-24 16:33:19 1 OUT 0 0
5010 19-Mar-24 07:05:15 1 IN 0 0
5014 19-Mar-24 07:31:19 1 IN 0 0
5014 19-Mar-24 16:30:50 1 OUT 0 0
5010 19-Mar-24 16:31:12 1 OUT 0 0
5010 20-Mar-24 07:05:15 1 IN 0 0
5014 20-Mar-24 07:31:19 1 IN 0 0
5014 20-Mar-24 16:30:50 1 OUT 0 0
5010 20-Mar-24 16:31:12 1 OUT 0 0
DESIRED RESULT
ID DATE TIME FP IN/OUT OTHERS1 OTHERS2
5010 18-Mar-24 06:59:10 1 IN 0 0
5014 18-Mar-24 07:11:00 1 IN 0 0
5014 18-Mar-24 16:32:09 1 OUT 0 0
5010 18-Mar-24 16:33:19 1 OUT 0 0
5010 19-Mar-24 07:05:15 1 IN 0 0
5014 19-Mar-24 07:31:19 1 IN 0 0
5014 19-Mar-24 16:30:50 1 OUT 0 0
5010 19-Mar-24 16:31:12 1 OUT 0 0