If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > is possible to use tyhis code in asp page?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-08-08, 12:05
sal21 sal21 is offline
Registered User
 
Join Date: Oct 2004
Posts: 61
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
Reply With Quote
  #2 (permalink)  
Old 05-11-08, 04:36
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
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
Twitter | Blog
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On