03. februar 2001 - 23:43
Der er
12 kommentarer og 1 løsning
Få dette \"update\" til at virke
Jeg her følgende kode til at opdatere bruger indstillinger i en database, men jeg kan ikke få det til at virke. Jeg vil geren have koden gennemgået, og rettet for de fejl, som der er, så jeg lige kan klippe det ind i min hjemmeside. -------------------------------------------- <form method=\"POST\" action=\"ret.asp?mode=gemdata\"> <table> <td width=\"36%\"><font size=\"2\"><b>Brugernavn:</b></font></td> <td width=\"64%\"><font size=\"2\"><%=rs(\"username\")%></font></td> </tr> <tr> <td width=\"36%\"><b><font size=\"2\">Kodeord:</font></b></td> <td width=\"64%\"><font size=\"2\"><input type=\"password\" name=\"password\" size=\"20\" style=\"font-family: Tahoma; color: #FFFFFF; font-size: 10 pt; font-weight: bold; background-color: #729BAF; border-style: double; border-color: #C9D9E1\" value=\"<%=rs(\"password\")%>\"></font></td> </tr> <tr> <td width=\"36%\"><b><font size=\"2\">Kodeord igen:</font></b></td> <td width=\"64%\"><font size=\"2\"><input type=\"password\" name=\"password2\" size=\"20\" style=\"font-family: Tahoma; color: #FFFFFF; font-size: 10 pt; font-weight: bold; background-color: #729BAF; border-style: double; border-color: #C9D9E1\" value=\"<%=rs(\"password\")%>\"></font></td> </tr> <tr> <td width=\"36%\"><b><font size=\"2\">Har du e-mail:</font></b></td> <td width=\"64%\"><select size=\"1\" name=\"email_status\" style=\"font-family: Tahoma; color: #FFFFFF; font-size: 10 pt; font-weight: bold; background-color: #729BAF; border-style: double; border-color: #C9D9E1\"> <option>Ja</option> <option selected>Nej</option> </select></td> </tr> <tr> <td width=\"36%\"><b><font size=\"2\">E-mail adresse:</font></b></td> <td width=\"64%\"><font size=\"2\"><input type=\"text\" name=\"email\" size=\"20\" style=\"font-family: Tahoma; color: #FFFFFF; font-size: 10 pt; font-weight: bold; background-color: #729BAF; border-style: double; border-color: #C9D9E1\" value=\"<%=rs(\"email\")%>\"></font></td> </tr> <tr> <td width=\"36%\"><b><font size=\"2\">Telefon:</font></b></td> <td width=\"64%\"><font size=\"2\"><input type=\"text\" name=\"telefon\" size=\"20\" style=\"font-family: Tahoma; color: #FFFFFF; font-size: 10 pt; font-weight: bold; background-color: #729BAF; border-style: double; border-color: #C9D9E1\" value=\"<%=rs(\"telefon\")%>\"></font></td> </tr> <tr> <td width=\"36%\"><b><font size=\"2\">Gren:</font></b></td> <td width=\"64%\"><select size=\"1\" name=\"Gren\" style=\"font-family: Tahoma; color: #FFFFFF; font-size: 10 pt; font-weight: bold; background-color: #729BAF; border-style: double; border-color: #C9D9E1\"> <option>Mikro</option> <option selected>Mini</option> <option>Junior</option> <option>Troppen</option> <option>Senior</option> <option>Ungdomsrep.</option> </select></td> </tr> <tr> <td width=\"36%\"><b><font size=\"2\">Medlemnr:</font></b></td> <td width=\"64%\"><font size=\"2\"><input type=\"text\" name=\"medlemnr\" size=\"20\" style=\"font-family: Tahoma; color: #FFFFFF; font-size: 10 pt; font-weight: bold; background-color: #729BAF; border-style: double; border-color: #C9D9E1\" value=\"<%=rs(\"medlemnr\")%>\"></font></td> </tr> <tr> <td width=\"36%\"><b><font size=\"2\">Startbillede:</font></b></td> <td width=\"64%\"><select size=\"1\" name=\"op_billed\" style=\"font-family: Tahoma; color: #FFFFFF; font-size: 10 pt; font-weight: bold; background-color: #729BAF; border-style: double; border-color: #C9D9E1\"> <option selected>Sejs Logo</option> <option>DDS Lilje</option> </select></td> </tr> <tr> <td width=\"36%\"><font color=\"#C9D9E1\" size=\"1\">.</font></td> <td width=\"64%\"><font color=\"#C9D9E1\" size=\"1\">.</font></td> </tr> <tr> <td width=\"36%\"> </td> <td width=\"64%\"><input type=\"submit\" value=\"Ret indstillinger\" name=\"B1\" style=\"font-family: Tahoma; color: #FFFFFF; font-size: 10 pt; font-weight: bold; background-color: #729BAF; border-style: double; border-color: #C9D9E1\"></td> </tr> </form> <% Conn.Close Set Conn = nothing Set SQLstmt = nothing End If End If mode = request(\"mode\") if mode=\"gemdata\" then if Session(\"userID\") = \"\" Then response.redirect (\"login.asp\") END IF if Session(\"userID\") <> \"\" then str_password = replace(request.form(\"password\"),\"\'\",\"\'\'\") str_password2 = replace(request.form(\"password2\"),\"\'\",\"\'\'\") If str_password <> str_password2 Then response.write \"<center><b>Du har ikke angivet 2 ens passwords.</b></center>\" else FUNCTION fixQuotes( theString ) fixQuotes = Replace( theString, \"\'\", \"\'\'\" ) END FUNCTION email_status = Request.Form( \"email_status\" ) Email = Request.Form( \"email\" ) telefon = Request.Form( \"telefon\" ) if telefon = \"\" then telefon = 0 gren = Request.Form( \"gren\" ) medlemnr = Request.Form( \"medlemnr\" ) op_billed = Request.Form( \"op_billed\" ) Set Conn = Server.CreateObject(\"ADODB.Connection\") Conn.Open \"DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=\" & server.MapPath(\"sejs.mdb\") SQLstmt = \"UPDATE DISTINCTROW adgangskoder SET username = \'\" & session(\"user-name\") &\"\', email_status = \'\" & fixQuotes(email_status) & \"\', password = \'\" & (str_password) & \"\', Email=\" & fixQuotes(Email) & \", telefon=\" & fixQuotes(telefon) & \", gren =\'\" & fixQuotes(gren) & \", op_billed =\'\" & fixQuotes(op_billed) & \"\', medlemnr=\'\" & fixQuotes(medlemnr) & \"\' WHERE userid = \" & session(\"userID\") \'response.write sqlstmt Conn.Execute (SQLstmt) Session(\"user-password\")= request.form(\"password\") Conn.Close Set Conn = nothing Set SQLstmt = nothing response.write(\"<center><br><br>Dine indstillinger er nu opdateret...<br><br></center>\") End If End If End If %> </form>
Annonceindlæg fra Cognizant
04. februar 2001 - 00:11
#1
Hvad er det mere konkret, der ikke virker?
04. februar 2001 - 00:28
#2
Når jeg vil opdatere noget skriver den: Microsoft OLE DB Provider for ODBC Drivers fejl \'80040e14\' [Microsoft][ODBC Microsoft Access-driver] Der er en syntaksfejl, fordi der mangler en operator. i forespørgselsudtrykket \"email@email.dk\". /spejder2/ret.asp, linje 230
04. februar 2001 - 04:27
#3
hvad format gemmer du Email\'en i ?
04. februar 2001 - 10:56
#4
hvis det er i access du merner, så er det et tekst felt.....
04. februar 2001 - 11:54
#5
Det er tilsyneladen i din SQLstmt den er gal, jeg går ud fra det er en lang linie. Jeg har prøvet at lave dette, håber det virker. SQLstmt = \"UPDATE DISTINCT ROW adgangskoder SET\" SQLstmt + SQLstmt & \" username = \'\" & session(\"user-name\") & \"\' AND\" SQLstmt + SQLstmt & \" email_status = \'\" & fixQuotes(email_status) & \"\' AND\" SQLstmt + SQLstmt & \" password = \'\" & (str_password) & \"\' AND\" SQLstmt + SQLstmt & \" Email= \'\" & fixQuotes(Email) & \"\' AND\" SQLstmt + SQLstmt & \" telefon=\" & fixQuotes(telefon) & \"\' AND\" SQLstmt + SQLstmt & \" gren =\'\" & fixQuotes(gren) & \"\' AND\" SQLstmt + SQLstmt & \" op_billed =\'\" & fixQuotes(op_billed) & \"\' AND\" SQLstmt + SQLstmt & \" medlemnr=\'\" & fixQuotes(medlemnr) & \"\' WHERE\" SQLstmt + SQLstmt & \" userid = \" & session(\"userID\") Stig
04. februar 2001 - 12:35
#6
Så får jeg denne meddelse: Der opstod en Microsoft VBScript-kørselsfejl fejl \'800a000d\' Typerne passer ikke sammen: \'SQLstmt\'
04. februar 2001 - 12:41
#7
Hej superole - Sæt \"\" på dem alle f.eks. (email) til (\"email\") Stig
04. februar 2001 - 17:08
#8
Her nu prøvet med \"\" om det giver følgende: Der opstod en Microsoft VBScript-kørselsfejl fejl \'800a000d\' Typerne passer ikke sammen: \'SQLstmt\' /spejder2/ret.asp, linje 228 i linje 228 står der: SQLstmt + SQLstmt & \" username = \'\" & session(\"user-name\") & \"\' AND\" Hvis der e rnogen der kan lave et andet script til mig, som kan det samme men er lettere at rette i, er det fint med mig
04. februar 2001 - 17:33
#9
Hej superole
Læg dine filer + database heri så vil jeg meget gerne kigge på det.
ftp://eks:pert@212.10.34.90 Stig
04. februar 2001 - 19:30
#10
Ok filen hedder eks.zip
04. februar 2001 - 20:32
#11
Hej superole - Her er siden. Jet har rettet dit/mit update, samt sat value på dine selections. Så at når der skydes ned i databasen kommer der en værdi med. <% Response.Buffer = True %> <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>Ny side 1</title> <link rel=\"stylesheet\" type=\"text/css\" href=\"grafik.css\"> </head> <body bgcolor=\"#C9D9E1\"> <div align=\"center\"> <center> <table border=\"1\" width=\"88%\" bordercolor=\"#000000\" cellspacing=\"0\" cellpadding=\"0\"> <tr> <td width=\"88%\" valign=\"top\"> <table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\"> <tr> <td width=\"100%\"> <p align=\"center\"><b><font size=\"4\" color=\"#729BAF\">Ret oplysninger</font></b></td> </tr> <tr> <td width=\"100%\"><font color=\"#C9D9E1\" size=\"1\">.</font></td> </tr> <tr> <% mode = request(\"mode\") if mode=\"\" then if Session(\"userID\") <> \"\" then Set Conn = Server.CreateObject(\"ADODB.Connection\") Set rs = Server.CreateObject(\"ADODB.Connection\") Conn.Open \"DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=\" & server.MapPath(\"sejs.mdb\") SQLstmt = \"SELECT * FROM adgangskoder WHERE userid = \" & session(\"userID\") Conn.Execute (SQLstmt) Set rs = conn.Execute(SQLstmt) %> <td width=\"100%\"> <p align=\"center\"><font size=\"2\">Indstillinger for: <%=rs(\"realname\")%></font></td> </tr> </center> <tr> <td width=\"100%\"> <p align=\"left\"><font color=\"#C9D9E1\" size=\"1\">.</font></td> </tr> <center> <tr> <td width=\"100%\"> <form method=\"POST\" action=\"ret.asp?mode=gemdata\"> <div align=\"center\"> <center> <table border=\"1\" width=\"72%\" bordercolor=\"#729BAF\" cellspacing=\"0\" cellpadding=\"0\"> <tr> <td width=\"36%\"><font size=\"2\"><b>Brugernavn:</b></font></td> <td width=\"64%\"><font size=\"2\"><%=rs(\"username\")%></font></td> </tr> <tr> <td width=\"36%\"><b><font size=\"2\">Kodeord:</font></b></td> <td width=\"64%\"><font size=\"2\"><input type=\"password\" name=\"password\" size=\"20\" style=\"font-family: Tahoma; color: #FFFFFF; font-size: 10 pt; font-weight: bold; background-color: #729BAF; border-style: double; border-color: #C9D9E1\" value=\"<%=rs(\"password\")%>\"></font></td> </tr> <tr> <td width=\"36%\"><b><font size=\"2\">Kodeord igen:</font></b></td> <td width=\"64%\"><font size=\"2\"><input type=\"password\" name=\"password2\" size=\"20\" style=\"font-family: Tahoma; color: #FFFFFF; font-size: 10 pt; font-weight: bold; background-color: #729BAF; border-style: double; border-color: #C9D9E1\" value=\"<%=rs(\"password\")%>\"></font></td> </tr> <tr> <td width=\"36%\"><b><font size=\"2\">Har du e-mail:</font></b></td> <td width=\"64%\"><select size=\"1\" name=\"email_status\" style=\"font-family: Tahoma; color: #FFFFFF; font-size: 10 pt; font-weight: bold; background-color: #729BAF; border-style: double; border-color: #C9D9E1\"> <option value=\"ja\">Ja</option> <option value=\"nej\">Nej</option> </select></td> </tr> <tr> <td width=\"36%\"><b><font size=\"2\">E-mail adresse:</font></b></td> <td width=\"64%\"><font size=\"2\"><input type=\"text\" name=\"email\" size=\"20\" style=\"font-family: Tahoma; color: #FFFFFF; font-size: 10 pt; font-weight: bold; background-color: #729BAF; border-style: double; border-color: #C9D9E1\" value=\"<%=rs(\"email\")%>\"></font></td> </tr> <tr> <td width=\"36%\"><b><font size=\"2\">Telefon:</font></b></td> <td width=\"64%\"><font size=\"2\"><input type=\"text\" name=\"telefon\" size=\"20\" style=\"font-family: Tahoma; color: #FFFFFF; font-size: 10 pt; font-weight: bold; background-color: #729BAF; border-style: double; border-color: #C9D9E1\" value=\"<%=rs(\"telefon\")%>\"></font></td> </tr> <tr> <td width=\"36%\"><b><font size=\"2\">Gren:</font></b></td> <td width=\"64%\"><select size=\"1\" name=\"Gren\" style=\"font-family: Tahoma; color: #FFFFFF; font-size: 10 pt; font-weight: bold; background-color: #729BAF; border-style: double; border-color: #C9D9E1\"> <option value=\"mikro\">Mikro</option> <option value=\"mini\">Mini</option> <option value=\"junior\">Junior</option> <option value=\"troppen\">Troppen</option> <option value=\"senior\">Senior</option> <option value=\"ungdomsrep\">Ungdomsrep.</option> </select></td> </tr> <tr> <td width=\"36%\"><b><font size=\"2\">Medlemnr:</font></b></td> <td width=\"64%\"><font size=\"2\"><input type=\"text\" name=\"medlemnr\" size=\"20\" style=\"font-family: Tahoma; color: #FFFFFF; font-size: 10 pt; font-weight: bold; background-color: #729BAF; border-style: double; border-color: #C9D9E1\" value=\"<%=rs(\"medlemnr\")%>\"></font></td> </tr> <tr> <td width=\"36%\"><b><font size=\"2\">Startbillede:</font></b></td> <td width=\"64%\"><select size=\"1\" name=\"op_billed\" style=\"font-family: Tahoma; color: #FFFFFF; font-size: 10 pt; font-weight: bold; background-color: #729BAF; border-style: double; border-color: #C9D9E1\"> <option selected>Sejs Logo</option> <option>DDS Lilje</option> </select></td> </tr> <tr> <td width=\"36%\"><font color=\"#C9D9E1\" size=\"1\">.</font></td> <td width=\"64%\"><font color=\"#C9D9E1\" size=\"1\">.</font></td> </tr> <tr> <td width=\"36%\"> </td> <td width=\"64%\"><input type=\"submit\" value=\"Ret indstillinger\" name=\"B1\" style=\"font-family: Tahoma; color: #FFFFFF; font-size: 10 pt; font-weight: bold; background-color: #729BAF; border-style: double; border-color: #C9D9E1\"></td> </tr> </table> </center> </div> </form> <% Conn.Close Set Conn = nothing Set SQLstmt = nothing End If End If mode = request(\"mode\") if mode=\"gemdata\" then if Session(\"userID\") = \"\" Then response.redirect (\"login.asp\") END IF if Session(\"userID\") <> \"\" then str_password = replace(request.form(\"password\"),\"\'\",\"\'\'\") str_password2 = replace(request.form(\"password2\"),\"\'\",\"\'\'\") If str_password <> str_password2 Then response.write \"<center><b>Du har ikke angivet 2 ens passwords.</b></center>\" else FUNCTION fixQuotes( theString ) fixQuotes = Replace( theString, \"\'\", \"\'\'\" ) END FUNCTION Set Conn = Server.CreateObject(\"ADODB.Connection\") Set RS = Server.CreateObject(\"ADODB.RecordSet\") Conn.Open \"DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=\" & server.MapPath(\"sejs.mdb\") SQLstr = \"SELECT * FROM adgangskoder WHERE userid = \" & session(\"userID\") RS.Open SQLstr, Conn, 3, 3 if (not RS.EOF) and (not RS.BOF) then RS(\"username\") = request.form(\"username\") RS(\"email_status\") = request.form(\"email-status\") RS(\"password\") = request.form(\"password\") RS(\"email\") = request.form(\"email\") RS(\"telefon\") = request.form(\"telefon\") RS(\"gren\") = request.form(\"gren\") RS(\"op_billed\") = request.form(\"op_billed\") RS(\"medlemnr\") = request.form(\"medlemnr\") RS.Update end if RS.Close set RS = Nothing conn.Close Set conn = nothing Set SQLstr = nothing response.write(\"<center><br><br>Dine indstillinger er nu opdateret...<br><br></center>\") End If End If End If %> </td> </tr> <tr> <td width=\"100%\"></td> </tr> <tr> <td width=\"100%\"></td> </tr> <tr> <td width=\"100%\"></td> </tr> <tr> <td width=\"100%\"></td> </tr> </table> <p> </center></td> </tr> </table> </div> </body> </html> Da jeg lavede dette, slog jeg alt med password fra. Stig
04. februar 2001 - 21:02
#12
Prøv denne SQL: SQLstmt = \"UPDATE DISTINCTROW adgangskoder SET username = \'\" & session(\"user-name\") &\"\', email_status = \'\" & fixQuotes(email_status) & \"\', password = \'\" & (str_password) & \"\', Email=\'\" & fixQuotes(Email) & \"\', telefon=\" & fixQuotes(telefon) & \", gren =\'\" & fixQuotes(gren) & \", op_billed =\'\" & fixQuotes(op_billed) & \"\', medlemnr=\" & fixQuotes(medlemnr) & \" WHERE userid = \" & session(\"userID\")
07. februar 2001 - 19:18
#13
>>sbarnney Det virkede fint, bortset fra at denne linie skal slettes, da den ellers sletter ens username i databasen, da man ikke kan rette det: RS(\"username\") = request.form(\"username\")
Kurser inden for grundlæggende programmering