Visualizzazione dei risultati da 1 a 3 su 3
  1. #1
    Utente di HTML.it
    Registrato dal
    Mar 2007
    Messaggi
    20

    Query di update su un campo di un database

    Ultima cosa poi non vi stresso più, ho questa pagina chiamata genera_pass.asp che deve generare una password generica per tutti i record nel mio database che ancora non ce l'hanno.

    <%
    'Our Function generatePassword accepts one parameter 'passwordLength'
    'passwordLength will obviously determine the password length.
    'The aplhanumeric character set is assigned to the variable sDefaultChars
    Function generatePassword(passwordLength)
    'Declare variables
    Dim sDefaultChars
    Dim iCounter
    Dim sMyPassword
    Dim iPickedChar
    Dim iDefaultCharactersLength
    Dim iPasswordLength
    'Initialize variables
    sDefaultChars="abcdefghijklmnopqrstuvxyzABCDEFGHIJ KLMNOPQRSTUVXYZ0123456789"
    iPasswordLength=passwordLength
    iDefaultCharactersLength = Len(sDefaultChars)
    Randomize'initialize the random number generator
    'Loop for the number of characters password is to have
    For iCounter = 1 To iPasswordLength
    'Next pick a number from 1 to length of character set
    iPickedChar = Int((iDefaultCharactersLength * Rnd) + 1)
    'Next pick a character from the character set using the random number iPickedChar
    'and Mid function
    sMyPassword = sMyPassword & Mid(sDefaultChars,iPickedChar,1)
    Next
    generatePassword = sMyPassword
    End Function
    %>
    <%
    set connection = Server.CreateObject("ADODB.Connection")
    Connection.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;Data Source=" & Server.MapPath(".\db1.mdb")
    Set Recordsx = CreateObject("ADODB.Recordset")
    sqltemp = "SELECT * FROM soci WHERE password is null"
    Recordsx.Open sqltemp, Connection,2,3
    dim password
    i=0
    Do While not Recordsx.eof
    data_source = "PROVIDER=MICROSOFT.JET.OLEDB.4.0;Data Source=" & Server.MapPath(".\db1.mdb")
    password = generatePassword(8)
    update_query = "UPDATE soci SET password='" & password & "' WHERE password is null"
    Set con = Server.CreateObject("ADODB.Connection")
    con.Open data_source
    con.Execute update_query
    con.Close
    Set con = Nothing
    loop
    Recordsx.close
    set Recordsx = Nothing

    %>
    quando la eseguo mi da questo errore

    Microsoft JET Database Engine (0x80040E14)
    Errore di sintassi nell'istruzione UPDATE.
    /database/genera_pass.asp, line 43
    la update mi da errore sia che metto la condizione where, sia che non la metto. la cosa strana è che cmq la select funziona perchè se provo a visualizzare il primo congnome della persona senza pass me lo da.....
    non riesco proprio a capire dove sta l'inghippo.
    da lo stesso errore se provo a togliere la select e metto direttamente l'update...

  2. #2
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    codice:
    update_query = "UPDATE soci SET [password]='" & password & "' WHERE password is null"
    Roby

  3. #3
    Utente di HTML.it
    Registrato dal
    Mar 2007
    Messaggi
    20
    grazie mille roby!!!!!!

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.