Avatar billede sonoxdk Nybegynder
29. januar 2002 - 22:20 Der er 9 kommentarer og
1 løsning

Opdatering af felter i database, problem...

Jeg har lavet følgende kode, men af en eller anden grund virker det overhovedet ikke, hvad har jeg gjort galt, og hvas skal laves om ?

<html>
<head>
    <title>test</title>
</head>

<body>

<head>

<meta http-equiv="Content-Language" content="da">
<meta name="MSSmartTagsPreventParsing" content="TRUE">
<META HTTP-EQUIV="imagetoolbar" CONTENT="no">

<LINK REL="stylesheet" HREF="styles/style.css" TYPE="text/css">

</head>

<body topmargin="0" leftmargin="0" background="GFX/BG.gif">
</center>
</div>
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="763" id="AutoNumber1" height="98">
<tr>
<td width="783" height="98" valign="top">
<table border="0" cellpadding="0" cellspacing="3" style="border-collapse: collapse" width="100%" id="AutoNumber21" height="18">
  <tr>
    <td width="100%"><!-- #include file="incwork/Top/Top.asp"--></td>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="3" style="border-collapse: collapse" width="766" id="AutoNumber9">
<tr>
<td width="142">
<table border="0" cellpadding="3" cellspacing="0" style="border-collapse: collapse; padding: 0" id="AutoNumber10" width="100%">
<tr>
<td width="100%" height="50" class="LblueU" valign="top">
<p style="margin-top: 0; margin-bottom: 0">
<%
Set myConn = Server.CreateObject("ADODB.Connection")
myConn.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("Data/DataBank.mdb")
%>

<%
strSQL = "SELECT * FROM rightframe Order By Id DESC "
Set rs1 = myConn.Execute(strSQL)

%>

<font face="Verdana" size="1" color="#000000"><%=Rs1("Nyhed")%>&nbsp;&nbsp;</font><p style="margin-top: 0; margin-bottom: 0">
<p style="margin-top: 0; margin-bottom: 0">
<p style="margin-top: 0; margin-bottom: 0">
<p style="margin-top: 0; margin-bottom: 0">
<p style="margin-top: 0; margin-bottom: 0">
</td>




</tr>
</table>
</td>
<td width="470" class="LblueU">
<p align="center">
<img border="0" src="GFX/All/logotop1.jpg"></td>
<td width="140">
<table border="0" cellpadding="3" cellspacing="0" style="border-collapse: collapse; " id="AutoNumber12" width="100%">
<tr>
<td width="100%" height="50" class="LblueU" valign="top">
<p style="margin-top: 0; margin-bottom: 0">
<%
strSQL = "SELECT * FROM leftframe Order By Id DESC "
Set rs2 = myConn.Execute(strSQL)

%>

<font face="Verdana" size="1" color="#000000"><%=Rs2("Nyhed")%></font></td>
<%
myConn.Close
Set myConn = Nothing
%>


</tr>

</table>
</td>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="3" style="border-collapse: collapse" width="100%" id="AutoNumber23" height="238">
  <tr>
    <td width="760%" height="238">
    <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="760" id="AutoNumber24" height="100%">
      <tr>
        <td width="142" class="LblueUM" valign="top"><p><!-- #include file="m.asp"--></td>
        <td valign="top" style="border-left-width: 1; border-right-width: 1; border-top-width: 1; border-bottom: 1px solid #000000" width="476" bgcolor="#F7EDD2">
        <div align="center">
          <center>
          <table border="0" cellpadding="3" cellspacing="0" style="padding:0; border-collapse: collapse" width="100%" bgcolor="#5B7DBC">
            <tr>
              <td width="472" style="border-top:1px solid #000000; border-bottom:1px solid #000000; padding:0; " valign="top" bgcolor="#D9E7F6">
              <!-- #include file="incwork/bar/bar.asp"--></td>
            </tr>
          </table>
          </center>
        </div>
        <div align="center">
          <center>
          <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="98%" id="AutoNumber26" bgcolor="#F7EDD2">
            <tr>

<td width="262" bgcolor="#F7EDD2" height="4">

<font size="1" face="Verdana"> </font>
<p style="margin-top: 0; margin-bottom: 0"><font face="Verdana" size="1"><b>
Her er du: </b>Ret artikel</font></td>
<td width="141" bgcolor="#F7EDD2" height="4">
<p style="margin-top: 0; margin-bottom: 0">
<font face="Verdana" size="1">
<b>Styrmandsmode:</b> <% If session("Styrmand") = true Then %>Yes <% end if %><% If session("Styrmand") = False Then %>No<% end if %></font></td>
<td width="64" bgcolor="#F7EDD2" valign="bottom" height="4">
<p align="center"><font face="Verdana" size="1">&nbsp;<a HREF="java script:window.print()"><img border="0" src="gfx/All/ikoner/print.gif" alt="Udskriv denne artikel :-)" align="middle" width="18" height="18"><span style="vertical-align: bottom"><a href="java script:window.print()">udskiv</a></span></font></td>
            </tr>
          </table>
          </center>
        </div>
        <div align="center">
          <center>
          <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="98%" id="AutoNumber25" background="GFX/All/D/p.gif" height="1">
            <tr>
              <td width="100%">
              <p style="margin-top: 0; margin-bottom: 0"></td>
            </tr>
          </table>
          </center>
        </div>
        <div align="center">
          <center>
          <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="98%" id="AutoNumber27">
            <tr>
              <td width="100%" height="100%" valign="top">
              <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="100%" id="AutoNumber14" height="100%" bgcolor="#FFFFFF">
<tr>
<td width="100%" height="473" valign="top" bgcolor="#F7EDD2">
&nbsp;<div align="center">
<center>
<table border="0" cellspacing="0" style="border-collapse: collapse" id="AutoNumber1">
<tr>
<td width="100%" valign="top" style="padding:0; ">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" id="AutoNumber4">
<tr>
<td width="72%" height="333" valign="top">
<table border="0" width="318" bgcolor="#000000" cellspacing="1" cellpadding="0" height="178" align="center">
<tr>
<td width="316" bgcolor="#FFFFFF" valign="top">
<table width="66%" border="0" cellspacing="2" cellpadding="2" style="border-collapse: collapse" bordercolor="#111111">
<tr>
<td width="75%" valign="top" align="left" bgcolor="#FFFFFF">
<p align="center" style="margin-top: 0; margin-bottom: 0"> <font face="tahoma" size="2"><b>
<font face="Tahoma">
Ret Artikel</font></b></font><font face="Tahoma" size="2"> </font>
<p align="center" style="margin-top: 0; margin-bottom: 0">
<a href="LartEdit.asp"><font color="#000000" face="Tahoma" size="2">Tilbage Til
Oversigten</font></a></p>
<hr noshade size="1" color="#000000" width="90%" align="center">
<% Response.buffer = true %>
<% if
mode = "" then

Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "PROVIDER=MSDASQL;DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("Data/DataBank.mdb") & ";UID=admin;PWD=;"
Set rs = Server.CreateObject("ADODB.RecordSet")

strSQL = "Select * from subcat where SubcatID = " & Request.Querystring("SubcatID") & ""
rs.Open strSQL, Conn, 1, 3
%>
<font face="Tahoma" size="2"> </font>
<form method="post" action="Lartret.asp?mode=update">
<table width="317" border="0" cellspacing="0" cellpadding="2" style="border-collapse: collapse" bordercolor="#111111">
<tr>
<td class="skrift" width="154" valign="top" height="22">
<font face="Tahoma" size="2">Artikel:</font></td>
<td height="22" width="152">
<font face="Tahoma">
<input type="text" name="Subcatname" maxlength="100" class="bottom" value="<%=rs("Subcatname")%>" size="28"></font></td>
</tr>
<tr>
<td class="skrift" width="154" valign="top" height="11">
<font face="Tahoma" size="2">Oprettet af:</font></td>
<td height="11" width="152">
<font face="Tahoma">
<input name="addby" maxlength="100" class="bottom" value="<%=rs("addby")%>" size="28"></font></td>
</tr>
<tr>
<td class="skrift" width="154" valign="top" height="6">
<font face="Tahoma" size="2">Brødtext:</font></td>
<td height="6" width="152">
    <textarea cssfil="main.css" picmappe="billeder" style="behavior:url(ae/ae.htc)" name="denmark" rows="1" cols="20"><%=rs("denmark")%></textarea></td>
</tr>
<tr>
<td class="skrift" width="154" valign="top" height="3">
<font face="Tahoma" size="2">kategori:</font></td>
<td height="3" width="152">
<font face="Tahoma">
<input name="Catid" maxlength="100" class="bottom" value="<%=rs("catid")%>" size="28"></font></td>
</tr>
<tr>
<td class="skrift" width="154" valign="top" height="2">
<font face="Tahoma" size="2">LinkDolink</font></td>
<td height="2" width="152">
<font face="Tahoma">
<input name="link" maxlength="100" class="bottom" value="<%=rs("link")%>" size="28"></font></td>
</tr>
<tr>
<td class="skrift" width="306" valign="top" height="1" colspan="2">
</td>
</tr>
</table>
<font face="Tahoma">
<input type="text" name="subcatid" value="<%=rs("subcatID")%>" size="20">
</font>
<p align="center">
<font face="Tahoma"><font size="2">
<br>
</font>
<input type="submit" value="Ret" name="knap" class="bottom"><font size="2">
</font>
<font size="2">&nbsp;</p>
</form>
<%
rs.Close
Set rs = Nothing
Conn.Close
Set Conn = Nothing
end if %> </font></font>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</center>
</div>
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="85%" id="AutoNumber2">
<tr>
<td width="100%"></td>
</tr>
</table>
</center>
</div></td>
</tr>
</table>
</td>
            </tr>
          </table>
          </center>
        </div>
        </td>
        <td width="142" class="LblueU" valign="top"><!-- #include file="incwork/ushow/Ushow.asp"-->&nbsp;</td>
      </tr>
    </table>
    </td>
  </tr>
</table>
</td>
</tr>
</table>
</center>
</div>

<div align="center">
  <center>
  <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="760" id="AutoNumber20" height="36">
    <tr>
      <td width="100%" height="36" valign="top">
      <p align="center"><!-- #include file="incwork/Bottom/bottom.asp"--></td>
    </tr>
  </table>
  </center>
</div>
<% Response.buffer = true
Set conn = Server.CreateObject("ADODB.Connection")
Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ="&Server.MapPath("data/Databank.mdb")
%>
<% if mode = "update" then
Set rs = Server.CreateObject("ADODB.Recordset")
sql = "select * from subcat where subcatid = '" & Request("subcatid") & "'"
rs.open sql, conn, 1, 3
                           
if Request.ServerVariables("REQUEST_METHOD") = "POST" then
rs.update
rs("Subcatname") = Server.HTMLEncode(Request("subcatname"))
rs("addby") = Server.HTMLEncode(Request("addby"))
rs("denmark") = Server.HTMLEncode(Request("denmark"))
rs("Catid") = Server.HTMLEncode(Request("Catid"))
rs("link") = Server.HTMLEncode(Request("link"))
rs.update
Response.Redirect "LartRediger.asp?subcatid=" & Request("subcatid") & ""
end if %>
<%
'Lukker connection
conn.close
set conn = nothing
%>
<%
rs.close
set rs = nothing
%>
</body>
</html>
Avatar billede entracore Nybegynder
29. januar 2002 - 22:33 #1
Kunne du ikke komme med en fejlmeddelse også kun poste de linier kode hvor fejlen opstår :-)
Avatar billede sonoxdk Nybegynder
29. januar 2002 - 22:35 #2
Syntax error
Lartret.asp, line 171, column 2
if
-^
Avatar billede sonoxdk Nybegynder
29. januar 2002 - 22:37 #3
jeg vil tro fejlen ligger i dette
<% Response.buffer = true
Set conn = Server.CreateObject("ADODB.Connection")
Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ="&Server.MapPath("data/Databank.mdb")
%>
<% if mode = "update" then
Set rs = Server.CreateObject("ADODB.Recordset")
sql = "select * from subcat where subcatid = '" & Request("subcatid") & "'"
rs.open sql, conn, 1, 3
                           
if Request.ServerVariables("REQUEST_METHOD") = "POST" then
rs.update
rs("Subcatname") = Server.HTMLEncode(Request("subcatname"))
rs("addby") = Server.HTMLEncode(Request("addby"))
rs("denmark") = Server.HTMLEncode(Request("denmark"))
rs("Catid") = Server.HTMLEncode(Request("Catid"))
rs("link") = Server.HTMLEncode(Request("link"))
rs.update
Response.Redirect "LartRediger.asp?subcatid=" & Request("subcatid") & ""
end if %>
<%
'Lukker connection
conn.close
set conn = nothing
%>
<%
rs.close
set rs = nothing
%>
</body>
</html>
Avatar billede entracore Nybegynder
29. januar 2002 - 22:58 #4
if mode = "update" then //Lukker du denne if sætning ???
Avatar billede entracore Nybegynder
29. januar 2002 - 22:59 #5
<% if mode = "update" then
Set rs = Server.CreateObject("ADODB.Recordset")
sql = "select * from subcat where subcatid = '" & Request("subcatid") & "'"
rs.open sql, conn, 1, 3
                           
if Request.ServerVariables("REQUEST_METHOD") = "POST" then
rs.update
rs("Subcatname") = Server.HTMLEncode(Request("subcatname"))
rs("addby") = Server.HTMLEncode(Request("addby"))
rs("denmark") = Server.HTMLEncode(Request("denmark"))
rs("Catid") = Server.HTMLEncode(Request("Catid"))
rs("link") = Server.HTMLEncode(Request("link"))
rs.update
Response.Redirect "LartRediger.asp?subcatid=" & Request("subcatid") & ""
end if
END IF //HER VIL JEG LUKKE SÆTNINGEN !!!!!!!!!
%>
Avatar billede sonoxdk Nybegynder
29. januar 2002 - 23:11 #6
får denne fejl nu
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'SubcatID ='.
Lartret.asp, line 178
Avatar billede sonoxdk Nybegynder
29. januar 2002 - 23:14 #7
efter hvad jeg kan tyde mig frem til er det her
rs.Open strSQL, Conn, 1, 3
%>
<font face="Tahoma" size="2"> </font>
<form method="post" action="Lartret.asp?mode=update">
Avatar billede sonoxdk Nybegynder
29. januar 2002 - 23:15 #8
dog ført når man trykker på send knappen!
Avatar billede entracore Nybegynder
29. januar 2002 - 23:36 #9
I den linie hvor du redirecter skal du skrive følgende i stedet for:

Response.Redirect "LartRediger.asp?subcatid=" & Request("subcatid")
Avatar billede sonoxdk Nybegynder
09. februar 2002 - 16:25 #10
Nej, nej virker ikke
Avatar billede Ny bruger Nybegynder

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.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester



IT-JOB

Cognizant Technology Solutions Denmark ApS

Test Manager

Cognizant Technology Solutions Denmark ApS

Energy Trading Project Manager – Consulting