codice:
<%
Dim adoCn
Set adoCn = CreateObject("ADODB.Connection")
With adoCn
.Provider="Microsoft.Jet.OLEDB.4.0"
.ConnectionString="Data Source="&Server.MapPath("VENDUVAL.XLS")&";Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"""
.Open
End With
If err.number <> 0 Then
Pagina = Request.ServerVariables("url")
%>
<script language="javascript">
alert("Errore nel formato del file.\nERRORE N. <%=err.number%>\n<%=err.Description%>\n<%=err.Source%>\n<%=pagina%>");
location.href("default.asp");
</script>
<%
Response.End
End If
strVariabileDataVenduto = formatDBDate(Date(),"mysql")
DataVenduto = Upload.Form("DataVenduto")
strDataVenduto = formatDBDate(DataVenduto,"mysql")
Dim doRs
Set doRs = CreateObject("ADODB.Recordset")
stQuery = "SELECT * from [VENDUVAL$]"
With doRs
Set .ActiveConnection = adoCn
.Open stQuery
End With
strVariabileData = (doRs(1).name)
strVariabileMarchio = (doRs(2).name)
response.write strVariabileMarchio &"
"
Dim adoRs
Set adoRs = CreateObject("ADODB.Recordset")
strQuery = "SELECT * from [VENDUVAL$] "
strQuery = strQuery & " WHERE "
strQuery = strQuery & " ["& strVariabileData &"] <> 'Codice a barre' "
strQuery = strQuery & " and ["& strVariabileData &"] <> 'DALLA DATA:' "
strQuery = strQuery & " and ["& strVariabileData &"] <> 'Categoria merceologica:' "
strQuery = strQuery & " and ["& strVariabileData &"] <> 'Marchio:' "
strQuery = strQuery & " and ["& strVariabileData &"] <> 'Linea:'"
response.write strQuery &"
"
With adoRs
Set .ActiveConnection = adoCn
.Open strQuery
End With
If adoRs.EOF then
%>
<script language="javascript">
function NumeroCasuale(Da,A) {
return Math.floor((A-Da+1) * Math.random() +Da);
}
alert("Nessun dato da importare.");
location.href("../mySql/default.asp?nocache="+NumeroCasuale(1,99999);
</script>
<%
Else
for i=0 to adoRs.fields.count -1
response.Write(adoRs(i).name&" ") 'visualizzo i nomi dei campi per sfizio
next
response.Write("
NUMERO CAMPI: "&adoRs.fields.count&"
") ' lo stesso il numero dei campi
adoRs.MoveFirst
Do While Not adoRs.Eof
for i = 0 to adoRs.fields.count -1
valore_campo = adoRs(i)
next
response.write adoRs(1) &" ---> adoRs1
"
response.write adoRs(3) &" ---> adoRs3
"
response.write adoRs(4) &" ---> adoRs4
"
response.write adoRs(10) &" ---> adoRs10
"
response.write adoRs(11) &" ---> adoRs11
"
response.write adoRs(13) &" ---> adoRs13
"
response.write adoRs(15) &" ---> adoRs15
"
response.write adoRs(16) &" ---> adoRs16
"
response.write adoRs(17) &" ---> adoRs17
"
response.write adoRs(18) &" ---> adoRs18
"
strVarComodo1 = CDBL(adoRs(1) & "")
strVarComodo1 = Replace(strVarComodo1, ",", ".")
strVarComodo10 = CDBL(adoRs(10) & "")
strVarComodo10 = Replace(strVarComodo10, ",", ".")
strVarComodo11 = CDBL(adoRs(11) & "")
strVarComodo11 = Replace(strVarComodo11, ",", ".")
strVarComodo13 = CDBL(adoRs(13) & "")
strVarComodo13 = Replace(strVarComodo13, ",", ".")
strVarComodo15 = CDBL(adoRs(15) & "")
strVarComodo15 = Replace(strVarComodo15, ",", ".")
strVarComodo16 = CDBL(adoRs(16) & "")
strVarComodo16 = Replace(strVarComodo16, ",", ".")
IF IsNull(adoRs(17)) THEN
strVarComodo17 = (adoRs(17) & "")
strVarComodo17 = Replace(strVarComodo17, ",", ".")
else
strVarComodo17 = CDBL(adoRs(17) & "")
strVarComodo17 = Replace(strVarComodo17, ",", ".")
end if
IF IsNull(adoRs(18)) THEN
strVarComodo18 = (adoRs(18) & "")
strVarComodo18 = Replace(strVarComodo18, ",", ".")
else
strVarComodo18 = CDBL(adoRs(18) & "")
strVarComodo18 = Replace(strVarComodo18, ",", ".")
end if
If IsNull(adoRs(17)) then
strSQL = "INSERT INTO tabellavenduto "
strSQL = strSQL & " (DataVenduto, "
strSQL = strSQL & " DataCaricamento, "
strSQL = strSQL & " CodiceBarre, "
strSQL = strSQL & " CodiceArrivo, "
strSQL = strSQL & " Descrizione, "
strSQL = strSQL & " Esistenza, "
strSQL = strSQL & " Qta, "
strSQL = strSQL & " ValoreMov, "
strSQL = strSQL & " ValoreCosto, "
strSQL = strSQL & " Differenza, "
strSQL = strSQL & " Margine) "
strSQL = strSQL & " VALUES "
strSQL = strSQL & " ("& strDataVenduto &", "
strSQL = strSQL & " "& strVariabileDataVenduto &", "
strSQL = strSQL & " "& strVarComodo1 &", "
strSQL = strSQL & " '"& adoRs(3) &"', "
strSQL = strSQL & " '"& adoRs(4) &"', "
strSQL = strSQL & " "& strVarComodo10 &", "
strSQL = strSQL & " "& strVarComodo11 &", "
strSQL = strSQL & " "& strVarComodo13 &", "
strSQL = strSQL & " "& strVarComodo15 &", "
strSQL = strSQL & " "& strVarComodo16 &", "
strSQL = strSQL & " "& strVarComodo18 &")"
else
strSQL = "INSERT INTO tabellavenduto "
strSQL = strSQL & " (DataVenduto, "
strSQL = strSQL & " DataCaricamento, "
strSQL = strSQL & " CodiceBarre, "
strSQL = strSQL & " CodiceArrivo, "
strSQL = strSQL & " Descrizione, "
strSQL = strSQL & " Esistenza, "
strSQL = strSQL & " Qta, "
strSQL = strSQL & " ValoreMov, "
strSQL = strSQL & " ValoreCosto, "
strSQL = strSQL & " Differenza, "
strSQL = strSQL & " Margine) "
strSQL = strSQL & " VALUES "
strSQL = strSQL & " ("& strDataVenduto &", "
strSQL = strSQL & " "& strVariabileDataVenduto &", "
strSQL = strSQL & " "& strVarComodo1 &", "
strSQL = strSQL & " '"& adoRs(3) &"', "
strSQL = strSQL & " '"& adoRs(4) &"', "
strSQL = strSQL & " "& strVarComodo10 &", "
strSQL = strSQL & " "& strVarComodo11 &", "
strSQL = strSQL & " "& strVarComodo13 &", "
strSQL = strSQL & " "& strVarComodo15 &", "
strSQL = strSQL & " "& strVarComodo16 &", "
strSQL = strSQL & " "& strVarComodo17 &")"
end if
objconn.Execute(strSQL)
response.write strSQL &"
"
adoRs.MoveNext
Loop
end if
doRs.close
Set doRs = Nothing
adoRs.close
Set adoRs = Nothing
adoCn.Close
Set adoCn = Nothing
%>
<script language="javascript">
function NumeroCasuale(Da,A) {
return Math.floor((A-Da+1) * Math.random() +Da);
}
alert("Importazione eseguita correttamente.\nIl file: <%=NewFileName%>\nè stato importato nel DataBase Magazzino.");
location.href("../mySql/default.asp?nocache="+NumeroCasuale(1,99999);
</script>