Ma sono io ho è aruba? database access query semplice a non funge !!!...

martedì 07 dicembre 2010 - 01.40
Tag Elenco Tags  SQL Server 2000  |  Access (.mdb)  |  Javascript  |  VBScript

bromuro Profilo | Newbie

ciao a tutti sono nuovo ho costruito grazie a vari script e notti insonne ,un 'efficente programma newsletter per adattarlo su servizi aruba (con timer delay etc)
comunque sto impazzendo a creare un sistema che
mi controlli un semplice array dove da form gli trasmetto alcuni indirizzi email da cancellare nel
database
quindi poi in automatico cancelli gli indirizzi che non mi servono in un colpo solo

ho provato con questa query funziona ma se ce un indirizzo doppio mi cancella solo il primo
e mi lascia nel database ACCESS su server ARUBA la copia dell'indirizzo che in teoria dovrebbe cancellarli entrambi visto che gli faccio fare il loop if not .eof

risultato alcuni indirizzi vengono cancellati altri con doppi rimangono nel record db

Spero di essermi fatto capire da qualcuno e che possa risolvere il problema

COME FUNZIONA :
procedura da form inserisco indirizzi emails da cancellare ---> vengono ricevuti da un'array
che lo splitta , mi conta le righe etc --->l'array sposta le righe una ad una (record)
poi il viene trasmesso il tutto nel DB , una volta finito di leggere l'array (1) (se l'email esiste)
dopo la cancellazione incrementa di una riga la lettura dell'array in ciclo stesso for next . fino all'ultimo record
risultato vengono cancellati tutti record ma se ce un record doppio ovvero un'email registrata due o tre volte per errore mi cancella solo il primo record ... la cosa strana e anche che se tento di rimettere l'utente (email) 1° che ho appena cancellato il database lo accetta e lo attiva nel database
ma se lo cancello un'altra volta me lo rimette nel database assieme al vecchio doppione
boh sto andando fuori di testa
perfavore datemi una mano


PAGINA DI CANCELLAZIONE AUTOMATICA ASP UTENTI DA CANCELLARE DA LISTA FORM
===========================================================================
<%@LANGUAGE = VBScript%>
<!--#include file="inc/common.asp"-->
<!--#include file="inc/ChkAdm.asp"-->
<!--#include file="header.asp"-->
<!--METADATA TYPE="typelib" UUID="CD000000-8B95-11D1-82DB-00C04FB1625D" NAME="CDO for Windows 2000 Type Library" -->
<!--METADATA TYPE="typelib" UUID="00000205-0000-0010-8000-00AA006D2EA4" NAME="ADODB Type Library" -->

<html>
<HEAD>

<SCRIPT LANGUAGE="JAVASCRIPT" TYPE="text/javascript">
<!-- Begin

function copy() {
textRange = document.extractor.output.createTextRange();
textRange.execCommand("RemoveFormat");
textRange.execCommand("Copy");
}
function paste() {
textRange = document.extractor.input.createTextRange();
textRange.execCommand("RemoveFormat");
textRange.execCommand("Paste");
}
function findEmail() {
var email = "No email address detected";
var a = 0;
var ingroup = 0;
var separator = "new";
var string = "";
var groupby = "";

if (separator == "new") separator = "\n";
if (separator == "other") separator = document.extractor.othersep.value;
var rawemail = document.extractor.input.value.match(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+)/gi);
var norepeat = new Array();
var filtermail = new Array();
if (rawemail) {
if (string){
x = 0;
for (var y=0; y<rawemail.length; y++) {
if (rawemail[y].search(string) >= 0) {
filtermail[x] = rawemail[y];
x++;
}
}
rawemail = filtermail;
}

for (var i=0; i<rawemail.length; i++) {
var repeat = 0;

// Check for repeated emails routine
for (var j=i+1; j<rawemail.length; j++) {
if (rawemail[i] == rawemail[j]) {
repeat++;
}
}

// Create new array for non-repeated emails
if (repeat == 0) {
norepeat[a] = rawemail[i];
a++;
}
}
if (document.extractor.sort.checked) norepeat = norepeat.sort(); // Sort the array
email = "";
// Join emails together with separator
for (var k = 0; k < norepeat.length; k++) {
if (ingroup != 0) email += separator;
// aggiunta virgola segno
email += ","+ norepeat[k];
ingroup++;


}
}

script1() ;
// Return array length
var count = norepeat.length;

// Print results
document.extractor.count.value = count;
document.extractor.output.value = email;
}
// End -->
</SCRIPT>

<script>

function script1() {
var e = document.getElementById("exporta");
e.innerHTML = '<input type="submit" class="button" value="exporta il testo">'
}
</script>
<STYLE TYPE="text/css">

BODY,td,th,ul,p { font: normal normal normal 8pt/1em Verdana; color: #000; }
textarea,input,select { font: normal normal normal 8pt/1em Verdana; color: #000; }


.bordercolor { background:#666 }
.maincolor { background:#CCC }
.button { background:#CCC }
.titlebarcolor { background:#007 }
.titlefont { font: normal normal bold 9pt/1em Arial; color: #FFF; }

</STYLE>
</HEAD>
<BODY>


<form method="post" name="extractor" action="importadatesto.asp?elabora=salva" method=""post"">
<DIV ALIGN="CENTER">
<TR><TD>
<TABLE CLASS="maincolor" CELLPADDING=4 CELLSPACING=0 BORDER=0>
<TR>
<TD VALIGN="TOP" ALIGN="CENTER" WIDTH="50%">
<TEXTAREA NAME="input" rows=8 cols=50 onBlur="findEmail();"></TEXTAREA>
</TD>
<TD VALIGN="TOP" ALIGN="CENTER" WIDTH="50%">

<TEXTAREA NAME="output" rows=8 cols=50 ></TEXTAREA>

</TD></TR>
<TR>
<TD VALIGN="TOP" ALIGN="CENTER">
</TD>
<TD VALIGN="TOP" ALIGN="CENTER">
</TD></TR>
<TR>
<TD VALIGN="TOP" ALIGN="LEFT" COLSPAN=2>
<INPUT TYPE="hidden" NAME="sort" id="sortbox">
</TD></TR>
<TR>
<TD VALIGN="TOP" ALIGN="LEFT" COLSPAN=2>
<div ALIGN="CENTER" id=exporta></DIV>
</TD>
</TR>

<TR>
<td>
<INPUT TYPE="RESET" CLASS="button" VALUE="Reset">
<INPUT NAME="count" SIZE=5 READONLY>
</TD>
</TR>
</FORM>

<tr>
<td >
<form name="file_upload" method="post" ENCTYPE="multipart/form-data" Action=" salva_allegati.asp?testodata=si">
<input type="file" size="20" name="Filename" class=button>
</td>


<tr>
<td>
<input type="hidden" name="uppo" value="update">
<input type="submit" class="button" value="salva nel db il file">
</td>
</tr>
</table>
</form>
<%

ConnectDB()
connectrst()

'Global variables
Dim lngTotalProcessed 'Counts the number of records processed




'******************************************
'*** Import form CSV file ****
'******************************************

Public Sub GetCsvSubscribers()



'Initilise variables
lngMemberImportCount = 0
lngMemberAlreadyImported = 0
lngMemberNoEmail = 0
lngTotalProcessed = 0
blnEmailOK = True
blnEmailExists = false


'########################



'conto le linee
sarryCsvFile = Split(Request.Form("output") , Chr(10))


'ottengo il numero di righe
lngTotalRecords = UBound(sarryCsvFile) + 1

'contatore
Response.Write("<script language=""JavaScript"">" & _

vbCrLf & " document.getElementById('subscribers').innerHTML = '" & lngTotalRecords & "';" & _
vbCrLf & "</script>")



'Loop through recordset
For lngCsvFileLoopCounter = 0 To (lngTotalRecords - 1)

'Initilise variables
blnEmailOK = True
blnEmailExists = false
strEmail = ""
strName = ""


'Count the number of files processed
lngTotalProcessed = lngTotalProcessed + 1

'Check to see if there is a comma before reading in data
If InStr(sarryCsvFile(lngCsvFileLoopCounter), ",") Then

'Read in the CSV file line into an array
sarryCsvFileLine = Split(sarryCsvFile(lngCsvFileLoopCounter),"," )


'Read in the details from the file
strName = sarryCsvFileLine(0)
If strName <> "" Then strName = strName
strEmail = LCase(sarryCsvFileLine(1))
If strEmail <> "" Then strEmail = Trim(strEmail)
End If


'If no email address for user display message
If strEmail = "" Then

lngMemberNoEmail = lngMemberNoEmail + 1

end if

'####### QUESTa query da i numeri !!! #### '


strSQL = "SELECT * FROM subscriber_list WHERE Email = '" &strEmail& "'"

With adorst

.CursorType = 3
.LockType = 3
.Open strSQL, adoCon


If NOT .EOF Then
blnEmailExists = true

response.write "<font color=yellow ><b>"&strEmail&"ce già ->"& .fields("email")& "</font><br>"

.delete
.movenext


' incremento
lngMemberAlreadyImported = lngMemberAlreadyImported + 1



end if


' questa opzione posso anche toglierla
' serve per updatare il database con nuovi utenti

'If the email doesn't already exsist then enter the email into the database
If blnEmailExists = False Then

response.write "<font color=gree><b>INSERITO: "&strEmail&"</font>"

'Add new record to a new recorset
.AddNew

'Set database fields
.Fields("Email") = Trim(Mid(strEmail, 1, 50))
if strName<>"" then
.Fields("name") = Trim(Mid(strname, 1, 50))
else
.Fields("name") = Trim(Mid(strEmail, 1, 50))
end if
.Fields("active") = "true"
.Fields("status") = "1"
.Fields("sub_date") = date()
.Update

.Requery

End If

.Close
End With

'############################fino a qua ###############################'



'Display on page number of subscribers to import
Response.Write(vbCrLf & "<script language=""JavaScript"">"& _
vbCrLf & " document.getElementById('imported').innerHTML = '" & lngMemberImportCount & "';" & _
vbCrLf & " document.getElementById('done').innerHTML = '" & lngMemberAlreadyImported & "';" & _
vbCrLf & " document.getElementById('noemail').innerHTML = '" & lngMemberNoEmail & "';" & _
vbCrLf & " document.getElementById('total').innerHTML = '" & lngTotalProcessed & "';" & _
vbCrLf & " document.getElementById('progress').innerHTML = '" & percentageCalculate(lngTotalProcessed, lngTotalRecords, 0) & "';" & _
vbCrLf & " document.getElementById('bar').style.width = '" & percentageCalculate(lngTotalProcessed, lngTotalRecords, 0) & "';" & _
vbCrLf & "</script>")


Next
Set adorst = Nothing
Set adocon = Nothing
End Sub

'******************************************
'*** Calculate Percentage ****
'******************************************

Private Function percentageCalculate(ByRef lngNumberProcessed, ByRef lngTotalToProcess, ByRef intDecPlaces)

'If there are no newsletters sent yet then format the percent by 0 otherwise an overflow error will happen
If lngTotalProcessed = 0 Then
percentageCalculate = FormatPercent(1, 1)

'Else read in the the percentage of newsletters sent
Else
percentageCalculate = FormatPercent((lngNumberProcessed / lngTotalToProcess), intDecPlaces)
End If

End Function

%>
<tr>
<table border="0" width=640 align=center>
<td id="bar" bgcolor=lightgreen style="width:100%;"></td>
<td id="progress" bgcolor=red ></td>
</tr>
</table>
<tr>
<table width=640 align=center border=0 cellspacing=0 cellpadding=0>
<tr>
<td>&nbsp;Campi trovati</td><td id="subscribers"></td>
<td>&nbsp;Campi vuoti</td><td id="noemail"></td>
<td>&nbsp;Campi già importati</td><td id="done"></td>
<td>&nbsp;Processati</td><td id="total"></td>
<td>&nbsp;Campi inseriti</td><td id="imported"><td>

</tr>
</table>
</body>
<%
Call GetCsvSubscribers()
%>
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5