Originariamente inviato da Roby_72
Non ho capito assolutamente nulla!
Errore?

Roby

questo è il nuovo codice funzionante. Solo una cosa dovrei cotrollare in fase di import i duplicati, che come indice hanno il rs SERVIZIO, come si fa?

codice:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Nuova pagina 1</title>
</head>

<body>

<%@ Language="VBScript" %>
<%
Dim var_DATACONT
Dim var_VAL
Dim fso
Dim fil

Set PROVADatabase = Server.CreateObject("ADODB.Connection")
path = Server.MapPath("db\prova.MDB")
strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & path & ";"
PROVADatabase.Open strConnection

Set ExportRecordSet = Server.CreateObject("ADODB.Recordset")
ExportRecordSet.Open "TOTALE_FSO", PROVADatabase, 1, 3, 512
ExportRecordSet.Index = "SERVIZIO"

Set fso = Server.CreateObject("Scripting.FileSystemObject")
vFile = Server.MapPath("DB\L0785.EPF")
Set fil = fso.OpenTextFile(vFile)

Do While Not fil.AtEndOfStream

RIGA = fil.ReadLine

If Len(Trim(RIGA)) > 0 Then
If InStr(Mid(RIGA, 1, 12), "DATA CONTAB.") > 0 Then
var_DATACONT = Mid(RIGA, 15, 10)
End If

If InStr(Mid(RIGA, 1, 11), "DIPENDENZA:") > 0 Then
var_DIP = Mid(RIGA, 14, 4)
End If

If InStr(Mid(RIGA, 5, 1), "-") > 0 And InStr(Mid(RIGA, 13, 1), "-") > 0 Then
var_COD = Mid(RIGA, 1, 3)
End If

If var_COD = "442" Then  'NEW LINE CONTROLLO SOLO SU UN CODICE BATCH

If InStr(Mid(RIGA, 50, 2), "55") Or InStr(Mid(RIGA, 50, 2), "36") > 0 And InStr(Mid(RIGA, 98, 1), "/") > 0 Then
var_NUMCC = Trim(Mid(RIGA, 1, 6))
var_NOME = Trim(Mid(RIGA, 8, 40))
var_CAUS = Mid(RIGA, 50, 2)
var_DARE = Trim(Mid(RIGA, 60, 14))
var_AVERE = Trim(Mid(RIGA, 80, 14))
var_VAL = Mid(RIGA, 96, 10)
var_MITT = Mid(RIGA, 107, 4)
var_ANOMAL = Trim(Mid(RIGA, 116, 10))

If Not fil.AtEndOfStream Then

RIGA = fil.ReadLine

var_DESCR = Trim(Mid(RIGA, 10, 36))
var_DESCR2 = Trim(Mid(RIGA, 96, 30))

RIGA = fil.ReadLine

var_ABI = Mid(RIGA, 17, 5)
var_CAB = Mid(RIGA, 23, 5)
var_IMP_PAG = Trim(Mid(RIGA, 29, 16))
var_nrass = Trim(Mid(RIGA, 45, 10))
var_MT = Trim(Mid(RIGA, 56, 4))

End If

If Not ExportRecordSet.BOF Then
   ExportRecordSet.MoveFirst
End If
   With ExportRecordSet

      ExportRecordSet.AddNew
      ExportRecordSet("DATA_CONT") = CStr(var_DATACONT)
      ExportRecordSet("DIP") = (var_DIP)
      ExportRecordSet("COD_BATCH") = var_COD
      ExportRecordSet("C_C") = (var_NUMCC)
      ExportRecordSet("NOMINATIVO") = var_NOME
      ExportRecordSet("CAUS") = var_CAUS
      ExportRecordSet("DARE") = var_DARE
      ExportRecordSet("AVERE") = var_AVERE
      ExportRecordSet("VAL") = CStr(var_VAL)
      ExportRecordSet("SPORT_MIT") = (var_MITT)
      ExportRecordSet("ANOM") = var_ANOMAL
      ExportRecordSet("DESCR") = var_DESCR
      
Select Case ExportRecordSet("DESCR")
       Case "RIMESSA ASSEGNI BANCARI INSOLUTI E P"
       ExportRecordSet("DESCR") = "RIM. ASS. INS. PROT."
End Select
      
      ExportRecordSet("CRO") = var_DESCR2
      ExportRecordSet("ABI") = var_ABI
      ExportRecordSet("CAB") = var_CAB
      ExportRecordSet("PAG_IMP") = var_IMP_PAG

      Select Case ExportRecordSet("PAG_IMP")
Case "IMPAG.N.ASS.BAN."
      ExportRecordSet("PAG_IMP") = "IMPAGATO"
Case "PAGATON.ASS.BAN."
      ExportRecordSet("PAG_IMP") = "PAGATO"
      Case "IMPAG.N.ASS.CIR."
      ExportRecordSet("PAG_IMP") = "IMP. A.C."
End Select

      ExportRecordSet("NR_ASS") = var_nrass
      ExportRecordSet("MT") = var_MT
      ExportRecordSet("SERVIZIO") = var_CAUS & "-" & var_ABI & "-" & var_CAB & "-" & var_nrass
      ExportRecordSet.Update
End With

End If
End If
End If

Loop

  ExportRecordSet.Close
  Set ExportRecordSet = Nothing
  PROVADatabase.Close
  Set PROVADatabase = Nothing

fil.Close
Set fil = Nothing
Set fso = Nothing

%>

</body>

</html>