Results 1 to 4 of 4

Thread: [RESOLVED] Error Updating a text file using ADO

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2004
    Posts
    541

    Resolved [RESOLVED] Error Updating a text file using ADO

    Hello, everyone,

    I'm trying to update a comma delimited text file using ADO. I am able to connect to it and do everything I need to it except update one of the fields.
    The same code works in every thing else I use it to update except text files.
    The error I'm getting is:

    err.Number
    -2147467259

    err.Description
    Updating data in a linked table is not supported by this ISAM.

    Here is my code:

    VB Code:
    1. Option Explicit
    2.  
    3. Sub Main()
    4.  
    5. Dim X As Long
    6.  
    7. Dim cn As New ADODB.Connection
    8. Dim rs As New ADODB.Recordset
    9.  
    10. Dim strPath As String
    11. Dim strSQL As String
    12.  
    13.     strSQL = "SELECT * FROM temp2.txt"
    14.     strPath = "G:\share\credit\Credit MIS\MIS Secure\"
    15.    
    16. DoCmd.Hourglass True
    17. cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=G:\share\credit\Credit MIS\MIS Secure\;Extended Properties=""text;HDR=Yes;FMT=Delimited"""
    18. rs.Open strSQL, cn, adOpenKeyset, adLockOptimistic
    19. DoCmd.Hourglass False
    20.  
    21. Do Until rs.EOF
    22. X = X + 1
    23.     If Format(rs!CallDT, "hh:mm:ss") >= "00:00:00" And Format(rs!CallDT, "hh:mm:ss") < "04:00:00" Then
    24.     rs!CallDT = Format(rs!CallDT, "Short Date") - 1
    25.     rs.Update
    26.         Else
    27.         rs!CallDT = Format(rs!CallDT, "Short Date")
    28.         rs.Update
    29.     End If
    30. rs.MoveNext
    31. Loop
    32.    
    33. rs.Close
    34. cn.Close
    35.  
    36. Set rs = Nothing
    37. Set cn = Nothing
    38.  
    39. End Sub

    So you know, I've also tried opening the recordset using these three methods:

    VB Code:
    1. rs.Open strSQL, cn, adOpenDynamic, adLockOptimistic
    2. rs.Open strSQL, cn, adOpenKeyset, adLockOptimistic
    3. rs.Open strSQL, cn, adOpenDynamic, adLockOptimistic

    What am I doing wrong?

    Thanks in advance!

    Strick

  2. #2

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2004
    Posts
    541

    Re: Error Updating a text file using ADO

    Hello,

    I am reading a field (long date format) in a text document and assigning it a value of Date - 1 if it is between 12:00 am and 4:00 am. I am then updating
    the field with the Date - 1 value.

    On a side note:
    I know I can read it into a array and output it in the desired format, but I'd rather use ADO to just update the text file. Due to the size of the file, I run out of memory if I do this in Access. So I decided to just use VB to update the text's recordset.

    Thanks

    Strick

  4. #4
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Error Updating a text file using ADO

    Hmm ...
    You cannot use JET (MS Access) OLEDB provider if you want to read text file: you must specify TEXT DRIVER ... here is a quick sample:
    VB Code:
    1. conn.Open "DRIVER={Microsoft Text Driver (*.txt; *.csv)};DBQ=" & App.Path & ";", "", ""
    2. RS.Open "select * from [test#txt]", conn, adOpenStatic, adLockReadOnly, adCmdText
    3. '...

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