Avatar billede iggipop Nybegynder
04. oktober 2004 - 12:51 Der er 8 kommentarer og
1 løsning

Fejl i SQL sætning

sql = "SELECT count(id_nr) as antal FROM brugersvogne WHERE VognID=" & lngRecordNo AND BrugerID=" & Session("UserID")&"

Den fejler...hvad er der galt ?
Avatar billede fennec Nybegynder
04. oktober 2004 - 12:53 #1
du mangler &" og har en forkert afslutning.

sql = "SELECT count(id_nr) as antal FROM brugersvogne WHERE VognID=" & lngRecordNo &" AND BrugerID=" & Session("UserID")
Avatar billede iggipop Nybegynder
04. oktober 2004 - 12:55 #2
Microsoft VBScript runtime error '800a01a8'

Object required: ''

/vogne_view_selected.asp, line 204



sql = "SELECT count(id_nr) as antal FROM brugersvogne WHERE VognID=" & lngRecordNo &" AND BrugerID=" & Session("UserID")
set rscount = dbc.Execute(sql)
antal = rscount("antal")
set rscount = nothing


linie 104 er
set rscount = dbc.Execute(sql)
Avatar billede fennec Nybegynder
04. oktober 2004 - 13:00 #3
du har ikke oprette forbindelse til databasen (dbc).

dbc.open "connection string"
Avatar billede iggipop Nybegynder
04. oktober 2004 - 13:03 #4
Hmmm
Mit problem er at jeg skal have kørt 2 SQL'er på samme side.

Du kan se hele siden her :

<%
'Dimension variables
Dim adoCon             'Holds the Database Connection Object
Dim rsGuestbook        'Holds the recordset for the record to be updated
Dim strSQL            'Holds the SQL query for the database
Dim lngRecordNo        'Holds the record number to be updated

'Read in the record number to be updated
lngRecordNo = CLng(Request.QueryString("ID"))

'Create an ADO connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")

'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("database.mdb")

'Set an active connection to the Connection object using DSN connection
'adoCon.Open "DSN=guestbook"

'Create an ADO recordset object
Set rsGuestbook = Server.CreateObject("ADODB.Recordset")

'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT * FROM vogne WHERE id_no=" & lngRecordNo

'Open the recordset with the SQL query
rsGuestbook.Open strSQL, adoCon
%>
<html>
<head>
<title>View_selected</title>
<link rel="stylesheet" type="text/css" href="style.css">

</head>
<body bgcolor="#F9F9F9" text="black">
<div align="center">
  <center>
    <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="530" id="AutoNumber2" bgcolor=#eeeeee>
      <tr>
        <td width="100%" class=head align=center>
              Artikelnr=<% = rsGuestbook("artikelnr") %>
        </td>
      </tr>
    </table>
  </center>
</div>

<div align="center">
  <center>
    <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="530" id="AutoNumber2">
      <tr>
        <td width="100%" class=text1 align=left>
                <a href="vogne_view.asp?sort=producent asc">
                  Tilbage
                </a>
        </td>
      </tr>
    </table>
  </center>
</div>
<br>
<div align="center">
    <table border="0" cellpadding="0" cellspacing="0" style="border-width:0px; border-collapse: collapse" width="530" id="table2" bordercolor="#000000">
        <tr>
            <td colspan="3" bgcolor=#d7dadf align=center class="text1" style="border-left-color: #000000; border-left-width: 1px; border-right-color: #000000; border-right-width: 1px; border-top-color: #000000; border-top-width: 1px">
            <b><% '= rsGuestbook("overskrift") %></b></td>
        </tr>
<tr>
            <td class="text1"  bgcolor=#eeeeee width="30%" style="border-style: none; border-width: medium">
            Artikelnr</td>
            <td class="text1"  bgcolor=#eeeeee style="border-style: none; border-width: medium" >
            :<% = rsGuestbook("Artikelnr") %></td>
        </tr>
        <tr>
            <td class="text1" width="30%" style="border-style: none; border-width: medium">
            Producent</td>
            <td class="text1" style="border-style: none; border-width: medium" >
            :<% = rsGuestbook("producent") %></td>
        </tr>
        <tr>
            <td class="text1"  bgcolor=#eeeeee width="30%" style="border-style: none; border-width: medium">Beskrivelse</td>
            <td class="text1"  bgcolor=#eeeeee style="border-style: none; border-width: medium" >
            :<% = rsGuestbook("beskrivelse") %></td>
        </tr>
        <tr>
            <td class="text1" width="30%" style="border-style: none; border-width: medium">Litrering</td>
            <td class="text1" style="border-style: none; border-width: medium" >
            :<% = rsGuestbook("Litrering") %></td>
        </tr>
        <tr>
            <td class="text1"  bgcolor=#eeeeee width="30%" style="border-style: none; border-width: medium">Farve</td>
            <td class="text1"  bgcolor=#eeeeee style="border-style: none; border-width: medium" >
            : <%=rsguestbook("farve")%></td>
        </tr>
                <tr>
            <td class="text1" width="30%" style="border-style: none; border-width: medium">Aksler</td>
            <td class="text1" style="border-style: none; border-width: medium" >
            : <%=rsguestbook("Aksler")%></td>
        </tr>
            <tr>
            <td class="text1" bgcolor=#eeeeee width="30%" style="border-style: none; border-width: medium">Selskab</td>
            <td class="text1" bgcolor=#eeeeee style="border-style: none; border-width: medium" >
            : <%=rsguestbook("Selskab")%></td>
        </tr>
       
            <tr>
            <td class="text1"  width="30%" style="border-style: none; border-width: medium">Art</td>
            <td class="text1" style="border-style: none; border-width: medium" >
            : <%=rsguestbook("Art")%></td>
        </tr>
       
            <tr>
            <td class="text1" bgcolor=#eeeeee width="30%" style="border-style: none; border-width: medium">UnderArt</td>
            <td class="text1" bgcolor=#eeeeee style="border-style: none; border-width: medium" >
            : <%=rsguestbook("Underart")%></td>
        </tr>
       
            <tr>
            <td class="text1"  width="30%" style="border-style: none; border-width: medium">Epoke</td>
            <td class="text1"  style="border-style: none; border-width: medium" >
            : <%=rsguestbook("Epoke")%></td>
        </tr>
       
            <tr>
            <td class="text1" bgcolor=#eeeeee width="30%" style="border-style: none; border-width: medium">Fotourl</td>
            <td class="text1" bgcolor=#eeeeee style="border-style: none; border-width: medium" >
            : <%=rsguestbook("fotourl")%></td>
        </tr>
       
            <tr>
            <td class="text1" width="30%" style="border-style: none; border-width: medium">udgivelsesår</td>
            <td class="text1" style="border-style: none; border-width: medium" >
            : <%=rsguestbook("Udgivelsesaar")%></td>
        </tr>
       
            <tr>
            <td class="text1" bgcolor=#eeeeee width="30%" style="border-style: none; border-width: medium">Beskrivelse</td>
            <td class="text1" bgcolor=#eeeeee style="border-style: none; border-width: medium" >
            : <%=rsguestbook("xbeskrivelse")%></td>
        </tr>
       
            <tr>
            <td class="text1" width="30%" style="border-style: none; border-width: medium">Spor</td>
            <td class="text1" style="border-style: none; border-width: medium" >
            : <%=rsguestbook("Spor")%></td>
        </tr>
       
            <tr>
            <td class="text1" bgcolor=#eeeeee  width="30%" style="border-style: none; border-width: medium">Land</td>
            <td class="text1" bgcolor=#eeeeee  style="border-style: none; border-width: medium" >
            : <%=rsguestbook("Land")%></td>
        </tr>
       
       
            <tr>
            <td class="text1" width="30%" style="border-style: none; border-width: medium">Link</td>
            <td class="text1" style="border-style: none; border-width: medium" >
            : <%=rsguestbook("Link")%></td>
        </tr>
       
       
            <tr>
            <td class="text1" bgcolor=#eeeeee width="30%" style="border-style: none; border-width: medium">Katalogår</td>
            <td class="text1" bgcolor=#eeeeee style="border-style: none; border-width: medium" >
            : <%=rsguestbook("Katalogaar")%></td>
        </tr>
       
       
            <tr>
            <td class="text1" width="30%" style="border-style: none; border-width: medium">Oprettet d.</td>
            <td class="text1" style="border-style: none; border-width: medium" >
            : <%=rsguestbook("Dato")%></td>
        </tr>
       
       
            <tr>
            <td class="text1" bgcolor=#eeeeee width="30%" style="border-style: none; border-width: medium">Oprettet kl</td>
            <td class="text1" bgcolor=#eeeeee  style="border-style: none; border-width: medium" >
            : <%=rsguestbook("Tid")%></td>
        </tr>
       
       
            <tr>
            <td class="text1" width="30%" style="border-style: none; border-width: medium">IP</td>
            <td class="text1" style="border-style: none; border-width: medium" >
            : <%=rsguestbook("IP")%></td>
        </tr>
       

       
    </table>
</div>
<br>

<br>
<center>
  <img src="images/530px.gif" align="textTop" width="530" height="1"></td>
</center>

</font>
<%

sql = "SELECT count(id_nr) as antal FROM brugersvogne WHERE VognID=" & lngRecordNo &" AND BrugerID=" & Session("UserID")
set rscount = dbc.Execute(sql)
antal = rscount("antal")
set rscount = nothing

If antal > 0 Then
Response.write ("Er I din samling")
Else
Response.Write ("<a href=""tilfoj_brugersvogn.asp?ID=" & rsGuestbook("ID_no") & """>")
Response.write ("<FONT size=1 face=verdana>Tilføj vogn til min samling</FONT>")
Response.Write ("</a>")
End If
%>
</body>
</html>
</font>
<%
'Reset server objects
rsGuestbook.Close
Set rsGuestbook = Nothing
Set adoCon = Nothing
%>

Hvordan skal jeg så gøre det ?
Avatar billede fennec Nybegynder
04. oktober 2004 - 13:21 #5
Du skal kun bruge en connection til databasen. Den har du allerede (adoCon) så du skal bare bruge den igen.

set rscount = adoCon.Execute(sql)
Avatar billede iggipop Nybegynder
04. oktober 2004 - 13:32 #6
Microsoft OLE DB Provider for ODBC Drivers error '80040e10'

[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.

/vogne_view_selected.asp, line 204


<%
'Dimension variables
Dim adoCon             'Holds the Database Connection Object
Dim rsGuestbook        'Holds the recordset for the record to be updated
Dim strSQL            'Holds the SQL query for the database
Dim lngRecordNo        'Holds the record number to be updated

'Read in the record number to be updated
lngRecordNo = CLng(Request.QueryString("ID"))

'Create an ADO connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")

'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("database.mdb")

'Set an active connection to the Connection object using DSN connection
'adoCon.Open "DSN=guestbook"

'Create an ADO recordset object
Set rsGuestbook = Server.CreateObject("ADODB.Recordset")

'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT * FROM vogne WHERE id_no=" & lngRecordNo

'Open the recordset with the SQL query
rsGuestbook.Open strSQL, adoCon
%>
<html>
<head>
<title>View_selected</title>
<link rel="stylesheet" type="text/css" href="style.css">

</head>
<body bgcolor="#F9F9F9" text="black">
<div align="center">
  <center>
    <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="530" id="AutoNumber2" bgcolor=#eeeeee>
      <tr>
        <td width="100%" class=head align=center>
              Artikelnr=<% = rsGuestbook("artikelnr") %>
        </td>
      </tr>
    </table>
  </center>
</div>

<div align="center">
  <center>
    <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="530" id="AutoNumber2">
      <tr>
        <td width="100%" class=text1 align=left>
                <a href="vogne_view.asp?sort=producent asc">
                  Tilbage
                </a>
        </td>
      </tr>
    </table>
  </center>
</div>
<br>
<div align="center">
    <table border="0" cellpadding="0" cellspacing="0" style="border-width:0px; border-collapse: collapse" width="530" id="table2" bordercolor="#000000">
        <tr>
            <td colspan="3" bgcolor=#d7dadf align=center class="text1" style="border-left-color: #000000; border-left-width: 1px; border-right-color: #000000; border-right-width: 1px; border-top-color: #000000; border-top-width: 1px">
            <b><% '= rsGuestbook("overskrift") %></b></td>
        </tr>
<tr>
            <td class="text1"  bgcolor=#eeeeee width="30%" style="border-style: none; border-width: medium">
            Artikelnr</td>
            <td class="text1"  bgcolor=#eeeeee style="border-style: none; border-width: medium" >
            :<% = rsGuestbook("Artikelnr") %></td>
        </tr>
        <tr>
            <td class="text1" width="30%" style="border-style: none; border-width: medium">
            Producent</td>
            <td class="text1" style="border-style: none; border-width: medium" >
            :<% = rsGuestbook("producent") %></td>
        </tr>
        <tr>
            <td class="text1"  bgcolor=#eeeeee width="30%" style="border-style: none; border-width: medium">Beskrivelse</td>
            <td class="text1"  bgcolor=#eeeeee style="border-style: none; border-width: medium" >
            :<% = rsGuestbook("beskrivelse") %></td>
        </tr>
        <tr>
            <td class="text1" width="30%" style="border-style: none; border-width: medium">Litrering</td>
            <td class="text1" style="border-style: none; border-width: medium" >
            :<% = rsGuestbook("Litrering") %></td>
        </tr>
        <tr>
            <td class="text1"  bgcolor=#eeeeee width="30%" style="border-style: none; border-width: medium">Farve</td>
            <td class="text1"  bgcolor=#eeeeee style="border-style: none; border-width: medium" >
            : <%=rsguestbook("farve")%></td>
        </tr>
                <tr>
            <td class="text1" width="30%" style="border-style: none; border-width: medium">Aksler</td>
            <td class="text1" style="border-style: none; border-width: medium" >
            : <%=rsguestbook("Aksler")%></td>
        </tr>
            <tr>
            <td class="text1" bgcolor=#eeeeee width="30%" style="border-style: none; border-width: medium">Selskab</td>
            <td class="text1" bgcolor=#eeeeee style="border-style: none; border-width: medium" >
            : <%=rsguestbook("Selskab")%></td>
        </tr>
       
            <tr>
            <td class="text1"  width="30%" style="border-style: none; border-width: medium">Art</td>
            <td class="text1" style="border-style: none; border-width: medium" >
            : <%=rsguestbook("Art")%></td>
        </tr>
       
            <tr>
            <td class="text1" bgcolor=#eeeeee width="30%" style="border-style: none; border-width: medium">UnderArt</td>
            <td class="text1" bgcolor=#eeeeee style="border-style: none; border-width: medium" >
            : <%=rsguestbook("Underart")%></td>
        </tr>
       
            <tr>
            <td class="text1"  width="30%" style="border-style: none; border-width: medium">Epoke</td>
            <td class="text1"  style="border-style: none; border-width: medium" >
            : <%=rsguestbook("Epoke")%></td>
        </tr>
       
            <tr>
            <td class="text1" bgcolor=#eeeeee width="30%" style="border-style: none; border-width: medium">Fotourl</td>
            <td class="text1" bgcolor=#eeeeee style="border-style: none; border-width: medium" >
            : <%=rsguestbook("fotourl")%></td>
        </tr>
       
            <tr>
            <td class="text1" width="30%" style="border-style: none; border-width: medium">udgivelsesår</td>
            <td class="text1" style="border-style: none; border-width: medium" >
            : <%=rsguestbook("Udgivelsesaar")%></td>
        </tr>
       
            <tr>
            <td class="text1" bgcolor=#eeeeee width="30%" style="border-style: none; border-width: medium">Beskrivelse</td>
            <td class="text1" bgcolor=#eeeeee style="border-style: none; border-width: medium" >
            : <%=rsguestbook("xbeskrivelse")%></td>
        </tr>
       
            <tr>
            <td class="text1" width="30%" style="border-style: none; border-width: medium">Spor</td>
            <td class="text1" style="border-style: none; border-width: medium" >
            : <%=rsguestbook("Spor")%></td>
        </tr>
       
            <tr>
            <td class="text1" bgcolor=#eeeeee  width="30%" style="border-style: none; border-width: medium">Land</td>
            <td class="text1" bgcolor=#eeeeee  style="border-style: none; border-width: medium" >
            : <%=rsguestbook("Land")%></td>
        </tr>
       
       
            <tr>
            <td class="text1" width="30%" style="border-style: none; border-width: medium">Link</td>
            <td class="text1" style="border-style: none; border-width: medium" >
            : <%=rsguestbook("Link")%></td>
        </tr>
       
       
            <tr>
            <td class="text1" bgcolor=#eeeeee width="30%" style="border-style: none; border-width: medium">Katalogår</td>
            <td class="text1" bgcolor=#eeeeee style="border-style: none; border-width: medium" >
            : <%=rsguestbook("Katalogaar")%></td>
        </tr>
       
       
            <tr>
            <td class="text1" width="30%" style="border-style: none; border-width: medium">Oprettet d.</td>
            <td class="text1" style="border-style: none; border-width: medium" >
            : <%=rsguestbook("Dato")%></td>
        </tr>
       
       
            <tr>
            <td class="text1" bgcolor=#eeeeee width="30%" style="border-style: none; border-width: medium">Oprettet kl</td>
            <td class="text1" bgcolor=#eeeeee  style="border-style: none; border-width: medium" >
            : <%=rsguestbook("Tid")%></td>
        </tr>
       
       
            <tr>
            <td class="text1" width="30%" style="border-style: none; border-width: medium">IP</td>
            <td class="text1" style="border-style: none; border-width: medium" >
            : <%=rsguestbook("IP")%></td>
        </tr>
       

       
    </table>
</div>
<br>

<br>
<center>
  <img src="images/530px.gif" align="textTop" width="530" height="1"></td>
</center>

</font>
<%

sql = "SELECT count(id_nr) as antal FROM brugersvogne WHERE VognID=" & lngRecordNo &" AND BrugerID=" & Session("UserID")
set rscount = adoCon.Execute(sql)
antal = rscount("antal")
set rscount = nothing

If antal > 0 Then
Response.write ("Er I din samling")
Else
Response.Write ("<a href=""tilfoj_brugersvogn.asp?ID=" & rsGuestbook("ID_no") & """>")
Response.write ("<FONT size=1 face=verdana>Tilføj vogn til min samling</FONT>")
Response.Write ("</a>")
End If
%>
</body>
</html>
</font>
<%
'Reset server objects
rsGuestbook.Close
Set rsGuestbook = Nothing
Set adoCon = Nothing
%>
Avatar billede iggipop Nybegynder
04. oktober 2004 - 13:40 #7
Fandt fejlen ... vognid skal være et tal-felt i databasen så virker det !
Takker mange gange...smid et svar!
Avatar billede fennec Nybegynder
04. oktober 2004 - 13:47 #8
ok
.o) <-- One Eyed Jack
Avatar billede iggipop Nybegynder
04. oktober 2004 - 13:55 #9
Hehe :o) Takker!
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