Avatar billede visual Nybegynder
22. december 2004 - 04:54 Der er 2 kommentarer

Noget Access og ASP for begyndere

har et problem med at få det til at virke:

<body>

<%
Dim amt
amt = Request.Querystring("sager")%>

<%
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath ("admin/nyheder.mdb")
SQL = "SELECT * FROM Sager WHERE id = "& Request.QueryString("id")
set rs = Conn.Execute(SQL)
%>

If rs.eof then


<div align="center">
  <table width="802" border="0" cellpadding="0" cellspacing="0">
    <tr>
      <td width="79" background="IMG/BgLeft.jpg"><img src="IMG/Blank.gif" width="79" height="1"></td>
      <td width="6" rowspan="3" bgcolor="#FFFFFF"><img src="IMG/Blank.gif" width="8" height="1"></td>
      <td width="628"><img src="IMG/MainBgTopTop.jpg" width="628" height="6"></td>
      <td width="10"><img src="IMG/Blank.gif" width="9" height="1"></td>
      <td width="79" background="IMG/BgRight.jpg"><img src="IMG/Blank.gif" width="79" height="1"></td>
    </tr>
    <tr>
      <td background="IMG/BgLeft.jpg">&nbsp;</td>
      <td background="IMG/MainBgTop.jpg"><table width="628" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td width="17" height="68"><div align="center"></div></td>
          <td width="222"><div align="left"><img src="IMG/MainTopLogo.jpg" width="161" height="21"></div></td>
          <td width="149"><div align="center"><img src="IMG/MenuTopOn01.jpg" width="94" height="21"></div></td>
          <td width="94"><div align="center"><a href="profil.htm"><img src="IMG/MenuTopOff02.jpg" width="37" height="21" border="0"></a></div></td>
          <td width="146"><div align="center"><a href="kontakt.htm"><img src="IMG/MenuTopOff03.jpg" width="52" height="21" border="0"></a></div></td>
          </tr>
        <tr>
          <td height="19">&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td height="19">&nbsp;</td>
          <td valign="top"><div align="left">

        response.write "<table width='222' border='0'><tr><td width='9'><img src='IMG/MenuDot.jpg' width='6' height='6'></td><td width='203' class='menu'>" & rs("Adresse") & "</td></tr></table>" & vbCrLf

</div></td>
          <td colspan="3" valign="top"><table width="359" border="0">
            <tr>
              <td width="353" height="23"><div align="left" class="menu"><img src="IMG/MainBigName01.jpg" width="252" height="12"><br>
                <br>
              </div></td>
              </tr>
            <tr>
              <td height="97" class="textgrey"><p align="left">STED: <span class="textred">rs("adresse")<br>
              </span>STØRRELSE: <span class="textred">rs("størrelse")  m&sup2;<br>
              </span>ÅRGANG:<span class="textred">rs("årgang") <br>
              </span>BESKRIVELSE:<span class="textred">rs("beskrivelse") & "vbCrLf" & "<br>")<br>
              </span>PLANTEGNING:<strong class="textred"><a href="rs("link")" target="_blank">Åben plantegning</a><br>
</strong></p>
                </td>
            </tr>
            <tr>
              <td height="170" class="textgrey"><div align="left"></div></td>
            </tr>
          </table></td>
          </tr>
      </table>
      </td>
      <td rowspan="2" bgcolor="#FFFFFF">&nbsp;</td>
      <td background="IMG/BgRight.jpg">&nbsp;</td>
    </tr>
    <tr>
      <td background="IMG/BgLeft.jpg">&nbsp;</td>
      <td><img src="IMG/MainBgBottom.jpg" width="628" height="93" border="0" usemap="#Map">
        <map name="Map">
          <area shape="rect" coords="1,63,48,92" href="http://www.enovision.dk" target="_blank">
        </map></td>
      <td background="IMG/BgRight.jpg">&nbsp;</td>
    </tr>
  </table>
</div>
        rs.movenext
    loop
end if
RS.Close
  Connect.Close
  Set RS = Nothing
  Set Connect = nothing
%>
</body>
Avatar billede hirtshals Nybegynder
22. december 2004 - 07:36 #1
If rs.eof then

Skal være

If not rs.eof then for at du kan movenext og loope
Avatar billede hirtshals Nybegynder
22. december 2004 - 07:40 #2
Du blander Server og klien kode sammen Koden skal se således ud

<%
Dim amt
amt = Request.Querystring("sager")%>

<%
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath ("admin/nyheder.mdb")
SQL = "SELECT * FROM Sager WHERE id = "& Request.QueryString("id")
set rs = Conn.Execute(SQL)

If not rs.eof then
%>

<div align="center">
  <table width="802" border="0" cellpadding="0" cellspacing="0">
    <tr>
      <td width="79" background="IMG/BgLeft.jpg"><img src="IMG/Blank.gif" width="79" height="1"></td>
      <td width="6" rowspan="3" bgcolor="#FFFFFF"><img src="IMG/Blank.gif" width="8" height="1"></td>
      <td width="628"><img src="IMG/MainBgTopTop.jpg" width="628" height="6"></td>
      <td width="10"><img src="IMG/Blank.gif" width="9" height="1"></td>
      <td width="79" background="IMG/BgRight.jpg"><img src="IMG/Blank.gif" width="79" height="1"></td>
    </tr>
    <tr>
      <td background="IMG/BgLeft.jpg">&nbsp;</td>
      <td background="IMG/MainBgTop.jpg"><table width="628" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td width="17" height="68"><div align="center"></div></td>
          <td width="222"><div align="left"><img src="IMG/MainTopLogo.jpg" width="161" height="21"></div></td>
          <td width="149"><div align="center"><img src="IMG/MenuTopOn01.jpg" width="94" height="21"></div></td>
          <td width="94"><div align="center"><a href="profil.htm"><img src="IMG/MenuTopOff02.jpg" width="37" height="21" border="0"></a></div></td>
          <td width="146"><div align="center"><a href="kontakt.htm"><img src="IMG/MenuTopOff03.jpg" width="52" height="21" border="0"></a></div></td>
          </tr>
        <tr>
          <td height="19">&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td height="19">&nbsp;</td>
          <td valign="top"><div align="left">

        response.write "<table width='222' border='0'><tr><td width='9'><img src='IMG/MenuDot.jpg' width='6' height='6'></td><td width='203' class='menu'>" & rs("Adresse") & "</td></tr></table>" & vbCrLf

</div></td>
          <td colspan="3" valign="top"><table width="359" border="0">
            <tr>
              <td width="353" height="23"><div align="left" class="menu"><img src="IMG/MainBigName01.jpg" width="252" height="12"><br>
                <br>
              </div></td>
              </tr>
            <tr>
              <td height="97" class="textgrey"><p align="left">STED: <span class="textred">rs("adresse")<br>
              </span>STØRRELSE: <span class="textred"><%=rs("størrelse")%>  m&sup2;<br>
              </span>ÅRGANG:<span class="textred"><%=rs("årgang")%> <br>
              </span>BESKRIVELSE:<span class="textred"><%=rs("beskrivelse") & "vbCrLf" & %>"<br>")<br>
              </span>PLANTEGNING:<strong class="textred"><a href='"<%=rs("link")%>"' target="_blank">Åben plantegning</a><br>
</strong></p>
                </td>
            </tr>
            <tr>
              <td height="170" class="textgrey"><div align="left"></div></td>
            </tr>
          </table></td>
          </tr>
      </table>
      </td>
      <td rowspan="2" bgcolor="#FFFFFF">&nbsp;</td>
      <td background="IMG/BgRight.jpg">&nbsp;</td>
    </tr>
    <tr>
      <td background="IMG/BgLeft.jpg">&nbsp;</td>
      <td><img src="IMG/MainBgBottom.jpg" width="628" height="93" border="0" usemap="#Map">
        <map name="Map">
          <area shape="rect" coords="1,63,48,92" href="http://www.enovision.dk" target="_blank">
        </map></td>
      <td background="IMG/BgRight.jpg">&nbsp;</td>
    </tr>
  </table>
</div>

<%
    rs.movenext
    loop
end if
RS.Close
Connect.Close
Set RS = Nothing
Set Connect = nothing
%>
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