/ Forside / Teknologi / Udvikling / ASP / Nyhedsindlæg
Login
Glemt dit kodeord?
Brugernavn

Kodeord


Reklame
Top 10 brugere
ASP
#NavnPoint
smorch 9259
Harlekin 1866
molokyle 1040
Steffanst.. 758
gandalf 657
smilly 564
gibson 560
cumano 530
MouseKeep.. 480
10  Random 410
vælge tabel i SQL
Fra : Preben Jensen


Dato : 09-01-03 14:37


Hej.

Jeg har en DB hvor jeg skal det til at virke med en selectbox sådan at det
valgte i selectboxen
bliver sat ind i SQL, men jeg kan ikke rigtigt få det til at virke, er der
en der kan hjælpe ?
Select form og paging er på samme side.
Selectboxen skal gøre det at jeg trækker data fra en via den valgt tabel.
------------------------
Dim book
book = request.form("book")

<SELECT NAME="book" ALIGN="BOTTOM">
<OPTION SELECTED value="2002" >2002
<OPTION selected VALUE="2002">2003
</SELECT>


SQL = "SELECT * FROM book WHERE dato < Date() AND callsign LIKE '" &
Replace(Keyword, "'", "''") & "' Order By dato Desc, tid Desc"

--------------------------------

hvad jeg er nået til kan ses her www.pdcs.dk/test/singlecount.asp

--
Mvh. Preben J
www.pdcs.dk



 
 
Jakob Andersen (09-01-2003)
Kommentar
Fra : Jakob Andersen


Dato : 09-01-03 14:46

"Preben Jensen" <preben@[remove]pdcs.dk> wrote
> Jeg har en DB hvor jeg skal det til at virke med en
> selectbox sådan at det valgte i selectboxen

SQL = "SELECT * FROM " & book & " WHERE dato < Date() AND callsign LIKE '" &
Replace(Keyword, "'", "''") & "' Order By dato Desc, tid Desc"

--
Jakob Andersen



Preben Jensen (09-01-2003)
Kommentar
Fra : Preben Jensen


Dato : 09-01-03 15:56

"Jakob Andersen" <jakob@effectus.dk> skrev i en meddelelse
news:avjuc8$1ki7$1@news.cybercity.dk...
> "Preben Jensen" <preben@[remove]pdcs.dk> wrote
> > Jeg har en DB hvor jeg skal det til at virke med en
> > selectbox sådan at det valgte i selectboxen
>
> SQL = "SELECT * FROM " & book & " WHERE dato < Date() AND callsign LIKE '"
&
> Replace(Keyword, "'", "''") & "' Order By dato Desc, tid Desc"

Tak skal du have Jacob, det funker

--
Mvh. Preben J
www.pdcs.dk



Preben Jensen (09-01-2003)
Kommentar
Fra : Preben Jensen


Dato : 09-01-03 16:12

"Preben Jensen" <preben@[remove]pdcs.dk> skrev i en meddelelse
news:3e1d8dbd$0$205$edfadb0f@dread14.news.tele.dk...
> "Jakob Andersen" <jakob@effectus.dk> skrev i en meddelelse
> news:avjuc8$1ki7$1@news.cybercity.dk...
> > "Preben Jensen" <preben@[remove]pdcs.dk> wrote
> > > Jeg har en DB hvor jeg skal det til at virke med en
> > > selectbox sådan at det valgte i selectboxen
> >
> > SQL = "SELECT * FROM " & book & " WHERE dato < Date() AND callsign LIKE
'"
> &
> > Replace(Keyword, "'", "''") & "' Order By dato Desc, tid Desc"
>
> Tak skal du have Jacob, det funker

Ja det gør, men jeg var for hurtig, jeg får vist første side af resultatet,
næste side kan den så ikke vise.
Preben.



Christian M. Nielsen (09-01-2003)
Kommentar
Fra : Christian M. Nielsen


Dato : 09-01-03 19:46


"Preben Jensen" <preben@[remove]pdcs.dk> wrote in message
news:3e1d9193$0$201$edfadb0f@dread14.news.tele.dk...

> Ja det gør, men jeg var for hurtig, jeg får vist første side af
resultatet,
> næste side kan den så ikke vise.


Hvis du skal have mere hjælp, er vi nødt til at have nogle søge kriterier
at gå ud fra.

--

Mvh / Regards

-=< Christian >=-

What capital has 164 letters in its name? See my web page to find out.
http://www.cmnielsen.dk ICQ: 25308942
Destiny is not a matter of chance it is a matter of choice



Preben Jensen (10-01-2003)
Kommentar
Fra : Preben Jensen


Dato : 10-01-03 01:09

"Christian M. Nielsen" <christian@(REMOVE)cmnielsen(DOT)dk> skrev i en
meddelelse news:3e1dc36a$0$1757$ba624c82@nntp03.dk.telia.net...
>
> "Preben Jensen" <preben@[remove]pdcs.dk> wrote in message
> news:3e1d9193$0$201$edfadb0f@dread14.news.tele.dk...
>
> > Ja det gør, men jeg var for hurtig, jeg får vist første side af
> resultatet,
> > næste side kan den så ikke vise.
>
>
> Hvis du skal have mere hjælp, er vi nødt til at have nogle søge kriterier
> at gå ud fra.
Okay, håber ikke i river hovedet af mig, men her er næsten det hele.

<%
Option Explicit
Session.LCID = 1030
Dim word
word = request.form("word")
Const MODE_DEFAULT = 1
Const MODE_RESULTS = 2

Const DB_NAME = "dbase.mdb" ' Name of our database file
Const SCRIPT_NAME = "singlecount.asp" ' Name of this script

Const RECORDS_PER_PAGE = 5 ' Number of records per page

Dim nMode ' Current Mode

' Find out what mode we are in
nMode = CLng(Request.QueryString("Mode"))

' Depending on our mode we will do different things
Select Case nMode

Case MODE_RESULTS
' This is where all the results will show
ShowResults

Case Else ' This one is for MODE_DEFAULT or invalid modes all the same
' By default display the search form
ShowSearchForm
End Select

Private Function GetConnectionString()
GetConnectionString = "Driver={Microsoft Access Driver (*.mdb)};" & _
"DBQ=" & Server.MapPath(DB_NAME) & ";" & _
"UID=;PWD=;"
End Function

' Shows HTML page header
Public Function OutputPageHeader()
%>
<HTML>
<title>PDCS Pilot Flights List</title>
<link rel="stylesheet" type="text/css"
href="../../../style/style_service.css" title="">
<HEAD><TITLE></TITLE></HEAD>
<BODY>
<center>
<H3><A HREF="<%=SCRIPT_NAME%>">Back to start</A></H3>
</center>
<%
End Function

' Shows HTML page footer
Public Function OutputPageFooter()
%>
</BODY>
</HTML>
<%
End Function

' This function will display the search form
Private Function ShowSearchForm()
OutputPageHeader
%>
<!--
This form will direct user to itself with MODE_RESULTS mode
-->
<link rel="stylesheet" type="text/css"
href="../../../style/style_service.css" title="">
<center>
<FORM ACTION="<%=SCRIPT_NAME%>" METHOD="GET">
Callsign: <INPUT TYPE="text" NAME="Keyword" VALUE="<% Response.Write word
%>" size="7" maxlenght="6">
<br>
Year:
<SELECT NAME="book" ALIGN="BOTTOM">
<OPTION SELECTED value="2002" >2002
<OPTION selected VALUE="2003">2003
</SELECT>
<br>
<INPUT TYPE="submit" VALUE=" Search ">
<INPUT TYPE="hidden" NAME="Mode" VALUE="<%=MODE_RESULTS%>">
</FORM>
</center>
<%
OutputPageFooter
End Function

' This function will display the results of the search
Private Function ShowResults()
Dim strConn ' Database connection string
Dim SQL ' String that will have our SQL statments
Dim RS ' Recordset object
Dim Keyword ' Keyword for search
Dim nRecCount ' Number of records found
Dim nPageCount ' Number of pages of records we have
Dim nPage ' Current page number
Dim book
' Let's see what page are we looking at right now
nPage = CLng(Request.QueryString("Page"))

' Let's see what user wants to search for today :)
Keyword = Trim(Request.QueryString("Keyword"))
book = Trim(Request.QueryString("book"))
' define our SQL statment
' we will be looking for all the records in tblItem table
' where ItemName contains our Keyword
' do not forget to fix tick marks (single quotes) in our Keyword
SQL = "SELECT * FROM " & book & " WHERE dato < Date() AND callsign LIKE '"
& Replace(Keyword, "'", "''") & "' Order By dato Desc, tid Desc"

' Create our connection string
strConn = GetConnectionString()

' Time to create and open recordset
Set RS = Server.CreateObject("ADODB.Recordset")
RS.CursorLocation = 3 ' adUseClient
RS.Open SQL, strConn ' adOpenKeyset CursorType

' Start outputing HTML
OutputPageHeader

' Did we find anything?
If Not RS.Eof Then
' Let's deal with our findings

' Get records count
nRecCount = RS.RecordCount

' Tell recordset to split records in the pages of our size
RS.PageSize = RECORDS_PER_PAGE

' How many pages we've got
nPageCount = RS.PageCount

' Make sure that the Page parameter passed to us is within the range
If nPage < 1 Or nPage > nPageCount Then
' Ops - bad page number
' let's fix it
nPage = 1
End If

' Time to tell user what we've got so far
Response.Write "<center>"
Response.Write nRecCount & " records found matching """ & Keyword &
""".<br>"
Response.Write nPageCount & " pages of results.<br>"
Response.Write "Current page is " & nPage & ".<p>"

' Give user some navigation

' first page
' we link to this page with Page parameter = 1
Response.Write "<A HREF=""" & SCRIPT_NAME & _
"?Keyword=" & Keyword & _
"&Mode=" & MODE_RESULTS & _
"&Page=" & 1 & _
""">First Page</A>"
Response.Write "&nbsp;&nbsp;&nbsp;&nbsp;"

' Previous Page
' we link to this page with Page parameter = Current Page - 1
Response.Write "<A HREF=""" & SCRIPT_NAME & _
"?Keyword=" & Keyword & _
"&Mode=" & MODE_RESULTS & _
"&Page=" & nPage - 1 & _
""">Prev. Page</A>"
Response.Write "&nbsp;&nbsp;&nbsp;&nbsp;"

' Next Page
' we link to this page with Page parameter Current Page + 1
Response.Write "<A HREF=""" & SCRIPT_NAME & _
"?Keyword=" & Keyword & _
"&Mode=" & MODE_RESULTS & _
"&Page=" & nPage + 1 & _
""">Next Page</A>"
Response.Write "&nbsp;&nbsp;&nbsp;&nbsp;"

' Last Page
' we link to this page with Page parameter = nPageCount
Response.Write "<A HREF=""" & SCRIPT_NAME & _
"?Keyword=" & Keyword & _
"&Mode=" & MODE_RESULTS & _
"&Page=" & nPageCount & _
""">Last Page</A>"

--
Mvh. Preben J
www.pdcs.dk



Søg
Reklame
Statistik
Spørgsmål : 177560
Tips : 31968
Nyheder : 719565
Indlæg : 6408946
Brugere : 218888

Månedens bedste
Årets bedste
Sidste års bedste