hey acctually i want to retrive data from text file nd save it to sql database bt i just have to implement some conditions like if there are 3 entries exists in text file with the same ID but i just have to get only 2 of them so in what manner should i write the code....

Dim sbIDs As New System.Text.StringBuilder
            Dim sbPunchDateStamp As New System.Text.StringBuilder
            Dim sbPunchTimeStamp As New System.Text.StringBuilder

            For Each Str As String In My.Computer.FileSystem.ReadAllText(System.IO.Path.GetFullPath(ofd.FileName)).Split(vbCrLf)
                If String.IsNullOrEmpty(Str.Trim) Or Str.StartsWith("No") Then Continue For
                Dim arr As String() = Str.Trim.Split("	")

                Dim dt As Date = CType(arr(8), Date)
                sbIDs.Append(arr(2) & "|")
                sbPunchDateStamp.Append(dt.ToString("yyyyMMdd") & "|")
                Dim ds_sbPunchTimeStamp As DataSet
                sbPunchTimeStamp.Append(dt.ToString("HHmmss") & "|")
            Next

            Dim sql As String = _appConfig.GetValue("Sql.ConvertRawDataToAttendance")
            Dim arrParameters(2) As String
            arrParameters(0) = sbIDs.ToString
            arrParameters(1) = sbPunchDateStamp.ToString
            arrParameters(2) = sbPunchTimeStamp.ToString

            _dh.ExecuteNonQuery(sql, CommandType.StoredProcedure, arrParameters)
            PopupBox.Show("Attendance Saved succesfully.", "Information", PopupBox.CYButtons.OK, PopupBox.CYIcon.Information)

AND THE GIVEN TEXT FILE IS HAVIN THE FORMAT...

No TMNo EnNo DateTime
1 1 1 2011-05-26 17:54:17
2 1 1 2011-05-26 17:54:25
3 1 1 2011-06-01 13:54:58
4 1 2 2011-06-01 13:55:11
5 1 2 2011-06-01 14:20:38
6 1 8 2011-06-01 14:20:45
7 1 8 2011-06-01 14:20:46
8 1 2 2011-06-01 14:34:38
9 1 1 2011-06-01 14:34:43
10 1 3 2011-06-01 14:34:51
11 1 4 2011-06-01 14:35:04
12 1 4 2011-06-02 08:23:25
13 1 2 2011-06-02 08:23:28
14 1 8 2011-06-02 08:23:37
15 1 8 2011-06-02 08:23:38
16 1 3 2011-06-02 08:24:02
17 1 9 2011-06-02 08:29:24
18 1 7 2011-06-02 08:34:38
19 1 5 2011-06-02 08:36:30
20 1 6 2011-06-02 08:38:08
21 1 4 2011-06-02 14:32:26
22 1 3 2011-06-02 14:32:35
23 1 5 2011-06-02 14:32:42
24 1 6 2011-06-02 14:34:36

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.