Ciao ragazzi ho questo codice
codice:
<%'Open the database
dim news,studente,notiziatemp
studente=Request.Form("studente")
notiziatemp=Request.Form("notizia")
notizia=Replace(notiziatemp, "'", "''" )
news=cbool(Request.QueryString("ordina"))
dim objConn, strCon, objRS, strSQL, ident
if studente="tutti" then
dim objConn2, strCon2, objRS2, strSQL2, ident2
'****************** NEWS A TUTTI ******************************
Set objConn2 = Server.CreateObject("ADODB.Connection")
'*************************************
' CHANGE THE FOLLWING DATA SOURCE
' PATH TO POINT TO WHERE YOU HAVE
'*************************************
strCon2 = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("\mdb-database\studenti.mdb")
objConn2.connectionstring = strCon2
objConn2.Open
Set objRS2 = Server.CreateObject("ADODB.Recordset")
strSQL2 = "SELECT user FROM studenti"
' Open the Database
objRS2.Open strSQL2, objConn2
do while not objRS2.eof
studente=objRS2("user")
Set objConn = Server.CreateObject("ADODB.Connection")
'*************************************
' CHANGE THE FOLLWING DATA SOURCE
' PATH TO POINT TO WHERE YOU HAVE
'*************************************
strCon = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("\mdb-database\studenti.mdb")
objConn.connectionstring = strCon
objConn.Open
Set objRS = Server.CreateObject("ADODB.Recordset")
' Set the SQL Statement to get the information from the database
strSQL = "INSERT INTO news(studente,notizia,attiva) VALUES ('" & studente & "','" & notizia & "'," & 1 & ") "
objConn.Execute(strSQL)
objConn.Close
set objConn = nothing
objRS2.Movenext
loop
objConn2.Close
'****************** FINE NEWS A TUTTI ******************************
else
'****************** NEWS SINGOLA ******************************
Set objConn = Server.CreateObject("ADODB.Connection")
'*************************************
' CHANGE THE FOLLWING DATA SOURCE
' PATH TO POINT TO WHERE YOU HAVE
'*************************************
strCon = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("\mdb-database\studenti.mdb")
objConn.connectionstring = strCon
objConn.Open
Set objRS = Server.CreateObject("ADODB.Recordset")
' Set the SQL Statement to get the information from the database
strSQL = "INSERT INTO news(studente,notizia,attiva) VALUES ('" & studente & "','" & notizia & "'," & 1 & ") "
objConn.Execute(strSQL)
objConn.Close
set objConn = nothing
end if
'****************** FINE NEWS SINGOLA ******************************
%>
I dati vengono raccolti da una form nella pagina precedente
e vengono inseriti in un DB
se nella casella è del form si è selezionato tutti in automatico viene generato il messaggio per tutti gli user del db.
il tutto sembra funzionare soltanto che a volte (a random)
non viene inserito il contenuto della variabile notizia ma una stringa vuota.
Cosa sbaglio?