|
-
Jul 15th, 2004, 08:40 PM
#1
Thread Starter
New Member
visual basic 6.0
i want to read a text file and insert neccessary fields into access database. May i know how do i do it?
this is my text file:
Type Date Time Source Category Event User Computer
Success Audit 7/14/2004 10:04:30 AM Security Logon/Logoff 538 SYSTEM L340C53
Success Audit 7/14/2004 10:04:30 AM Security Logon/Logoff 538 SYSTEM L340C53
Success Audit 7/14/2004 10:01:44 AM Security Logon/Logoff 538 SYSTEM L340C53
Success Audit 7/14/2004 10:01:34 AM Security Logon/Logoff 540 SYSTEM L340C53
Success Audit 7/14/2004 10:01:34 AM Security Logon/Logoff 540 SYSTEM L340C53
and this is my code:
Private Sub Form_Load()
Dim strEvent As Integer
Dim strUser As String
Dim strComputer As String
Dim strDate As String
Dim strTime As String
Open "C:\miNE\test.txt" For Input As #1
IREC = 0
Do Until EOF(1)
IREC = IREC + 1
Line Input #1, strLine
If IREC > 1 Then
strEvent = Mid(strLine, 1, 4)
strUser = Mid(strLine, 6, 10)
strComputer = Mid(strLine, 12, 10)
strDate = Mid(strLine, 24, 10)
strTime = Mid(strLine, 36, 10)
rs.AddNew
rs("Event") = 0
rs("User") = 0
rs("Computer") = 0
rs("Date") = 0
rs("Time") = 0
rs.Update
End If
Loop
Close
rs.Close
cn.Close
End Sub
May i know whats wrong with the code?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|