Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2004
    Posts
    72

    Unanswered: is possible to use tyhis code in asp page?

    How to ...
    Is possible to use this code in asp page to import txt file?
    note: schema ini reside in the same dir of txt file source.
    in other case i have a txt file 49 mb...
    i have tested variuos other type code to import the file but all codes are very very slow, idea?

    Code:
    Sub uno()
    
        Dim objConnection
        Dim objRecordset
        Dim strPathtoTextFile
        'Dim TEST_RIGA As String, TEST1 As String, TEST2 As String
        Dim CONTA As Long
        '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:
        'E DEVE AVERE LO STESSO NOME DEL FILE DA IMPORTARE
        
        '[TABUALTI_132.txt]
        'Format = FixedLength
    
        'MaxScanRows = 25
        'CharacterSet = OEM
        'Col1=TEST Text Width 132
        
        '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
    
            TEST_RIGA = Empty
            TEST_RIGA = Len(objRecordset.Fields.Item("TEST"))
            If Len(Trim(TEST_RIGA)) > 1 Then
                TEST1 = objRecordset.Fields.Item("TEST")
                CONTA = CONTA + 1
            End If
            objRecordset.MoveNext
    
        Loop
    
    
        objRecordset.Close
        objConnection.Close
    
        Set objRecordset = Nothing
        Set objConnection = Nothing
    
    End Sub

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    You have some odd code there; you say you're looking for a text file but appear to be querying a table in a database.

    What are you trying to achieve?
    George
    Home | Blog

Posting Permissions

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