Results 1 to 2 of 2
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ADO and txt file... (vb.6)

    I test the import file via ADO and schema.ini
    But o to skip blank line in txt file?

    In old my code i use:
    ....
    if len(RIGA)>0 then
    'code to get line
    end if
    ....

    my new code:
    Sub uno()

    Dim objConnection
    Dim objRecordset
    Dim strPathtoTextFile
    'http://msdn.microsoft.com/it-it/library/ms123402.aspx
    'IL FILE INI DEVE RISIEDERE NELLA STESSA DIR DEL FILE DA IMPORTARE E DEVE ESSERE SIMILE A QUESTO:
    '[TABUALTI_132.txt]
    'Format = FixedLength

    'Col1=SIGLA Text Width 7
    'Col2=CodiceCliente Text Width 10
    'IL FILE INI DEVE RISIEDERE NELLA STESSA DIR DEL FILE DA IMPORTARE E DEVE ESSERE SIMILE A QUESTO:


    Const adOpenStatic = 3
    Const adLockOptimistic = 3
    Const adCmdText = &H1


    Set objConnection = CreateObject("ADODB.Connection")
    Set objRecordset = CreateObject("ADODB.Recordset")


    strPathtoTextFile = "C:EPF"


    objConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=" & strPathtoTextFile & ";" & _
    "Extended Properties=""text;HDR=YES;FMT=FixedLength"""


    objRecordset.Open "SELECT * FROM TABUALTI_132.txt", _
    objConnection, adOpenStatic, adLockOptimistic, adCmdText


    Do Until objRecordset.EOF
    'If TEST_RIGA > Null Then
    test = "Col1: " & objRecordset.Fields.Item("Sigla")
    test1 = "Col2: " & objRecordset.Fields.Item("CodiceCliente")
    ' End If
    objRecordset.MoveNext

    Loop


    objRecordset.Close
    objConnection.Close


    Set objRecordset = Nothing
    Set objConnection = Nothing


    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: ADO and txt file... (vb.6)

    Is there a field that you can use to test whether a record (line) is blank? The field should always be filled except in blank records.

Posting Permissions

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