strSQL = "SELECT count(*) as antal, [Document No_], [Line No_], [Sell-to Customer No_], Text, Font, TypeAndColor, Layout, Height, Quantity, Produced, ProducedBy, ProducedDateTime, Width FROM N_S_SYSTEM$PlotterJOb WHERE Produced = '1'"
if strDatoFra <> "" then strSQL = strSQL & " AND(ProducedDateTime BETWEEN CONVERT(smalldatetime,'" & strDatoFra & "', 105) AND CONVERT(smalldatetime, '" & strDatoTil &"', 105)) "
if strKundeNr <> "" then strSQL = strSQL & " AND [Sell-to Customer No_] LIKE '" & strKundeNr & "' "
if strDokuNo <> "" then strSQL = strSQL & " AND [Document No_] LIKE '%" & strDokuNo & "%' "
strSQL = strSQL & "ORDER BY ProducedDateTime DESC"
if Request.querystring("mode") = "search" then 'create an instance of the ADO connection and recordset objects Set Connection = Server.CreateObject("ADODB.Connection") Set rs = Server.CreateObject("ADODB.Recordset")
'open the connection to the database Connection.Open "constring"
'Open the recordset object executing the SQL statement and return records 'response.write "SQL: "& strSQL rs.Open strSQL,Connection response.write "Der er " & rs("antal") & " poster i databasen"
Det ville nok være en god ide, at smide antallet over i en variabel, hvis du nu skulle bruge antallet senere.. også efter at du har lukket forbindelsen til databasen..
Microsoft OLE DB Provider for SQL Server error '80040e14'
Column 'N_S_SYSTEM$PlotterJOb.Document No_' is invalid in the select list because it is not contained in an aggregate function and there is no GROUP BY clause.
/sider/search_plotter.asp, line 129
Her er min kode:
<%
'if Request.querystring("mode") = "search" then ' Set conn = Server.CreateObject("ADODB.Connection") 'conn.Open "Provider=sqloledb;Data Source=nssrv13;Initial Catalog=NAVNS;User Id=NSloginnews;Password=iqminus;"
Dim strSQL Dim strKundeNr Dim strDatoFra Dim strDokuNo Dim strDatoTil
strSQL = "SELECT count(*) as antal, [Document No_], [Line No_], [Sell-to Customer No_], Text, Font, TypeAndColor, Layout, Height, Quantity, Produced, ProducedBy, ProducedDateTime, Width FROM N_S_SYSTEM$PlotterJOb WHERE Produced = '1'"
if strDatoFra <> "" then strSQL = strSQL & " AND(ProducedDateTime BETWEEN CONVERT(smalldatetime,'" & strDatoFra & "', 105) AND CONVERT(smalldatetime, '" & strDatoTil &"', 105)) "
if strKundeNr <> "" then strSQL = strSQL & " AND [Sell-to Customer No_] LIKE '" & strKundeNr & "' "
if strDokuNo <> "" then strSQL = strSQL & " AND [Document No_] LIKE '%" & strDokuNo & "%' "
strSQL = strSQL & "ORDER BY ProducedDateTime DESC"
if Request.querystring("mode") = "search" then 'create an instance of the ADO connection and recordset objects Set Connection = Server.CreateObject("ADODB.Connection") Set rs = Server.CreateObject("ADODB.Recordset")
'Open the recordset object executing the SQL statement and return records 'response.write "SQL: "& strSQL rs.Open strSQL,Connection
%> <%
color = "#FFFFFF"
If rs.EOF Then Response.Write "<br>" Response.Write "<br>" Response.Write "<br>" Response.Write "<strong>" Response.Write("Ingen resultater af søgning.") Response.Write "</strong>" Else %>
<% if color = "#FFFFFF" then color = "#DDDDDD" else color = "#FFFFFF" rs.MoveNext wend %> </table> <% response.write "Der er " & rs("antal") & " poster i databasen" %> <%
rs.Close Set rs = Nothing Connection.Close Set Connection=nothing
Jeg har prøvet mig frem med forslag nr.2 og det virkede skam første gang. Men så er mit problem at man først kan få antallet når alle posterne er loopet igennem, jeg vil gerne kunne udskrive antallet i toppen af siden, så man ikke behøver at scrolle i bunden for at se hvormange resultater ens søgning gav... Kan det gøres hvis jeg bruger forslag nr. 2????
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.