Results 1 to 8 of 8

Thread: visual basic 6.0

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2004
    Posts
    5

    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?

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    You're better off asking in the VB6 forum
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Can't believe this , are those guys blind !!!

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: visual basic 6.0

    Originally posted by hunterboy



    May i know whats wrong with the code?
    How about you tell us what's wrong with the code?

    Have you tried it? What errors are you getting?

  5. #5

    Thread Starter
    New Member
    Join Date
    Jul 2004
    Posts
    5
    runtime error 424 . object required
    error occur at rs.AddNew

  6. #6
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787
    it should be

    VB Code:
    1. rs.addnew
    2. rs.fields("Whatever") = "Whatever you want"
    3. rs.fields("Whatever2") = "Whatever you want2"
    4. rs.update

  7. #7
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787
    also have you made a referance to the ADO,

    you best take a look at the guide in the database forum

  8. #8
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    The name of the reference is

    Microsoft ActiveX Data Objects 2.X

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width