25. april 2006 - 11:21Der er
16 kommentarer og 1 løsning
updatere db record
Hej
Jeg har lidt problemer med at få en opdatering af min db til at virke. jeg får bare:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[MySQL][ODBC 3.51 Driver][mysqld-4.1.12a-nt]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE UserID =36' at line 1
/mail_list.asp, line 461
min kode ser således ud:
<% if Request.Form("domain") = "1" then strDomain = "novatech.dk" else if Request.Form("domain") = "2" then strDomain = "novatechpolska.com" else if Request.Form("domain") = "3" then strDomain = "ntindustry.com" else strDomain = "No Domain!" strMail = Request.Form("mailbox") + "@" + strDomain strUserName = Request.Form("mailbox") + "@" + strDomain strHomeDir = "C:\MDAEMON\Users\" + strDomain + "\" + Request.Form("mailbox") +"\" %>
<%
SQL = "Update userlist WHERE UserID ="& Request.QueryString("UserID") set rs = Conn.execute(SQL)
Set rs = Server.CreateObject("ADODB.Recordset") rs.Open SQL, Conn, 3, 3
if Request.Form("username") <> "" then rs("FullName") = Request.Form("username") end if if Request.Form("password") <> "" then rs("Password") = Request.Form("password") end if if Request.Form("mailbox") <> "" then rs("Mailbox") = Request.Form("mailbox") end if if Request.Form("desc") <> "" then rs("msg") = Request.Form("desc") end if rs("Maildir") = strHomeDir rs("AllowAccess") = "1" rs("AllowChangeViaEmail") = "1" rs("KeepForwardedMail") = "1" if Request.Form("userrole") <> "" then rs("role") = Request.Form("userrole") end if if Request.Form("domain") <> "" then rs("DomainID") = Request.Form("domain") end if rs("loginname") = strUserName rs.Update rs.Close Set rs = Nothing Conn.Close set Conn = Nothing%>
<form method="POST" action="?mode=editmail"> <% SQL = "SELECT * FROM userlist WHERE UserID ="& Request.QueryString("UserID") set rs = Conn.execute(SQL) if rs.EOF then %> No Data, in the database were found! <% else %>
<b>Showing Mail for UserID:</b> <%=rs("UserID")%> <table border="1" cellspacing="2" cellpadding="2"> <tr> <td bgcolor="#999999"><strong>UserID:</strong></td> <td bgcolor="#cccccc"><%=rs("UserID")%></td> </tr> <tr> <td bgcolor="#999999"><strong>Full Name:</strong></td> <td bgcolor="#cccccc"><input type="text" name="username" value="<%=rs("FullName")%>" size="15"></td> </tr> <tr> <td bgcolor="#999999"><strong>User Name:</strong></td> <td bgcolor="#cccccc"><%=rs("loginname")%></td> </tr> <tr> <td bgcolor="#999999"><strong>User E-Mail:</strong></td> <td bgcolor="#cccccc"><%=rs("Mailbox")%>@<% if rs("DomainID") = "1" then response.write"novatech.dk" else if rs("DomainID") = "2" then response.write"novatechpolska.com" else if rs("DomainID") = "3" then response.write"ntindustry.com" else response.write"No Domain!" %></td> </tr> <tr> <td bgcolor="#999999"><strong>MailBox:</strong></td> <td bgcolor="#cccccc"><input type="text" name="mailbox" value="<%=rs("Mailbox")%>" size="15"></td> </tr> <tr> <td bgcolor="#999999"><strong>Domain:</strong></td> <td bgcolor="#cccccc"><% if rs("DomainID") = "1" then response.write"novatech.dk" else if rs("DomainID") = "2" then response.write"novatechpolska.com" else if rs("DomainID") = "3" then response.write"ntindustry.com" else response.write"No Domain!" %></td> </tr> <tr> <td bgcolor="#999999"><strong>Domain ID:</strong></td> <td bgcolor="#cccccc"><%=rs("DomainID")%></td> </tr> <tr> <td bgcolor="#999999"><strong>MailDir:</strong></td> <td bgcolor="#cccccc"><%=rs("MailDir")%></td> </tr> <tr> <td bgcolor="#999999"><strong>User Role:</strong></td> <td bgcolor="#cccccc"><%=rs("role")%> - <select name="userrole" size="1"> <option value="Limited">Limited</option> <option value="Normal">Normal</option> <option value="Design">Design</option> <option value="Sales">Sales</option> <option value="Admin">Admin</option> </select></td> </tr> <tr> <td bgcolor="#999999"><strong>Password:</strong></td> <td bgcolor="#cccccc"><input type="password" name="password" value="<%=rs("password")%>" size="24"></td> </tr> <tr> <td bgcolor="#999999"><strong>Action:</strong></td> <td bgcolor="#cccccc">-<a href="?mode=editmail&UserID=<%=rs("UserID")%>">[Save]</a>-[Delete]-</td> </tr> </table></form> <% end if %> <% end if %>
<% if mode = "editmail" then %> <% if Request.Form("domain") = "1" then strDomain = "novatech.dk" else if Request.Form("domain") = "2" then strDomain = "novatechpolska.com" else if Request.Form("domain") = "3" then strDomain = "ntindustry.com" else strDomain = "No Domain!" strMail = Request.Form("mailbox") + "@" + strDomain strUserName = Request.Form("mailbox") + "@" + strDomain strHomeDir = "C:\MDAEMON\Users\" + strDomain + "\" + Request.Form("mailbox") +"\" %>
Når jeg forsøger at køre Conn.execute(SQL) får jeg denne fejl
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[MySQL][ODBC 3.51 Driver][mysqld-4.1.12a-nt]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''' at line 1
/mail_list.asp, line 460
men bruger jeg response.write SQL virker det fint?
Update userlist SET FullName='test2', password='1234', role='Limited' WHERE UserID =45';
Dette betyder: Username=text Password=text Userrole=text UserID=text
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.