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