473,385 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Navigate in database

Hi!

I have a detail page that shows one spesific record based on the article ID.
I need to make a navigation on this detail page, with "previous article" and
"next article" links.
So, my question is how can I get the previous and next article ID based on
the article that is open??

I though about the MovePrevious and MoveNext methods, but it was no
success...
The SQL needs some parameters to get the correct records, like the example
below with "artID", "catID", "active", "custID".
My thoughs here is to open the record I'm in, move to previos record and get
the ID, move to next 2 times to get the next ID... Ofcouse this dont work
becouse of the artID in the SQL....?
<%
varID = Request.QueryString("id")

SQL = "SELECT artID, catID, active, custID from tblArticle where " &_
"((artID = '"&varID&"') AND (custID = '3') AND (active = '1'))"

set rsNavigate = server.CreateObject("adodb.recordset")
rsNavigate.Open SQL,connstring

rsNavigate.MovePrevious
dbPrev = rsNavigate.Fields("artID") 'Hoped this would give me the
previous ID..

rsNavigate.MoveNext
rsNavigate.MoveNext
dbNext = rsNavigate.Fields("artID") 'Hoped this would give me the next
ID...

rsNavigate.Close
set rsNavigate = nothing
%>
Can anyone please help me???
Vinnie :)
Jul 22 '05 #1
3 1381
If IsValidID(Clng(varID -1)) Then lPrevID=Clng(varID -1) Else lPrevID="NULL"
If IsValidID(Clng(varID +1)) Then lNextID=Clng(varID +1) Else lNextID="NULL"

Obviously you'll want to check to make sure the ID is valid before printing it to the page (did this on my freeware site).

Although I'm probably going to get crucified for doing it this way, I've used the following (modified a bit as I doubt you'll be using the fields I am).... works just fine for me;

<%
Function IsValidID(sID)
'// Allow numeric sID's only
If IsNumeric(sID)=False Then IsValidID=False: Exit Function

'// DB Connection etc goes here
objRst.Open "Select fldID From tblTable_Name order by fldID ASC", objDB, adOpenStatic, adLockReadOnly
Do While not fRst.eof
If objRst("fldID") = sID Then
IsValidID = True
Exit Do
End If
fRst.MoveNext
Loop
objRst.Close
End Function
%>

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

"Vinnie Davidson" <ad***@webressurs.no> wrote in message news:uy*************@TK2MSFTNGP12.phx.gbl...
Hi!

I have a detail page that shows one spesific record based on the article ID.
I need to make a navigation on this detail page, with "previous article" and
"next article" links.
So, my question is how can I get the previous and next article ID based on
the article that is open??

I though about the MovePrevious and MoveNext methods, but it was no
success...
The SQL needs some parameters to get the correct records, like the example
below with "artID", "catID", "active", "custID".
My thoughs here is to open the record I'm in, move to previos record and get
the ID, move to next 2 times to get the next ID... Ofcouse this dont work
becouse of the artID in the SQL....?


<%
varID = Request.QueryString("id")

SQL = "SELECT artID, catID, active, custID from tblArticle where " &_
"((artID = '"&varID&"') AND (custID = '3') AND (active = '1'))"

set rsNavigate = server.CreateObject("adodb.recordset")
rsNavigate.Open SQL,connstring

rsNavigate.MovePrevious
dbPrev = rsNavigate.Fields("artID") 'Hoped this would give me the
previous ID..

rsNavigate.MoveNext
rsNavigate.MoveNext
dbNext = rsNavigate.Fields("artID") 'Hoped this would give me the next
ID...

rsNavigate.Close
set rsNavigate = nothing
%>


Can anyone please help me???
Vinnie :)



Jul 22 '05 #2
Thanks for your answer!

If I understand this right, the code just add or remove 1 from the current
ID (varID). This would work fine if i knew that the previous og next ID is
the one I want, but I dont. I have to check if the previous or next ID has
the correct categoryID (catID), customerID (custID) and active = 1. If these
criteria dont match, the code should "jump" to next record .... think you
got the point.. :)

This is a "nut"for me....

"Steven Burn" <so*******@in-time.invalid> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
If IsValidID(Clng(varID -1)) Then lPrevID=Clng(varID -1) Else lPrevID="NULL"
If IsValidID(Clng(varID +1)) Then lNextID=Clng(varID +1) Else lNextID="NULL"

Obviously you'll want to check to make sure the ID is valid before printing
it to the page (did this on my freeware site).

Although I'm probably going to get crucified for doing it this way, I've
used the following (modified a bit as I doubt you'll be using the fields I
am).... works just fine for me;

<%
Function IsValidID(sID)
'// Allow numeric sID's only
If IsNumeric(sID)=False Then IsValidID=False: Exit Function

'// DB Connection etc goes here
objRst.Open "Select fldID From tblTable_Name order by fldID ASC",
objDB, adOpenStatic, adLockReadOnly
Do While not fRst.eof
If objRst("fldID") = sID Then
IsValidID = True
Exit Do
End If
fRst.MoveNext
Loop
objRst.Close
End Function
%>

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

"Vinnie Davidson" <ad***@webressurs.no> wrote in message
news:uy*************@TK2MSFTNGP12.phx.gbl...
Hi!

I have a detail page that shows one spesific record based on the article
ID.
I need to make a navigation on this detail page, with "previous article"
and
"next article" links.
So, my question is how can I get the previous and next article ID based on
the article that is open??

I though about the MovePrevious and MoveNext methods, but it was no
success...
The SQL needs some parameters to get the correct records, like the example
below with "artID", "catID", "active", "custID".
My thoughs here is to open the record I'm in, move to previos record and
get
the ID, move to next 2 times to get the next ID... Ofcouse this dont work
becouse of the artID in the SQL....?
<%
varID = Request.QueryString("id")

SQL = "SELECT artID, catID, active, custID from tblArticle where " &_
"((artID = '"&varID&"') AND (custID = '3') AND (active = '1'))"

set rsNavigate = server.CreateObject("adodb.recordset")
rsNavigate.Open SQL,connstring

rsNavigate.MovePrevious
dbPrev = rsNavigate.Fields("artID") 'Hoped this would give me the
previous ID..

rsNavigate.MoveNext
rsNavigate.MoveNext
dbNext = rsNavigate.Fields("artID") 'Hoped this would give me the
next
ID...

rsNavigate.Close
set rsNavigate = nothing
%>
Can anyone please help me???
Vinnie :)

Jul 22 '05 #3
On Thu, 24 Mar 2005 12:35:45 +0100, "Vinnie Davidson"
<ad***@webressurs.no> wrote:
Thanks for your answer!

If I understand this right, the code just add or remove 1 from the current
ID (varID). This would work fine if i knew that the previous og next ID is
the one I want, but I dont. I have to check if the previous or next ID has
the correct categoryID (catID), customerID (custID) and active = 1. If these
criteria dont match, the code should "jump" to next record .... think you
got the point.. :)

This is a "nut"for me....
In otherwords your ID isn't sequential, and you're just querying data
for the ID in question, correct? Might want to pull in all matching
records and then use recordset paging to accomplish your task. Take a
look at:

http://www.aspfaq.com/show.asp?id=2120

Jeff

"Steven Burn" <so*******@in-time.invalid> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
If IsValidID(Clng(varID -1)) Then lPrevID=Clng(varID -1) Else lPrevID="NULL"
If IsValidID(Clng(varID +1)) Then lNextID=Clng(varID +1) Else lNextID="NULL"

Obviously you'll want to check to make sure the ID is valid before printing
it to the page (did this on my freeware site).

Although I'm probably going to get crucified for doing it this way, I've
used the following (modified a bit as I doubt you'll be using the fields I
am).... works just fine for me;

<%
Function IsValidID(sID)
'// Allow numeric sID's only
If IsNumeric(sID)=False Then IsValidID=False: Exit Function

'// DB Connection etc goes here
objRst.Open "Select fldID From tblTable_Name order by fldID ASC",
objDB, adOpenStatic, adLockReadOnly
Do While not fRst.eof
If objRst("fldID") = sID Then
IsValidID = True
Exit Do
End If
fRst.MoveNext
Loop
objRst.Close
End Function
%>


Jul 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Joe Bond | last post by:
Hi. I have a simple MS Access 2000 form in which I enter some customer data. When the address field is entered I need to see if a duplicate record exists. I need to know this *right away* before...
1
by: Chicken Kebab Abdullah | last post by:
I am making a database of my movie collection and I have a form which Shows a DVD Code in a combo, and a list of the divx movies on the dvd on the right in a list box. The combo boxes bound...
0
by: katheo via AccessMonster.com | last post by:
Hello, I am using a data access page on a local secure server. As the user changes information, the data updates automatically in the database. But when the user goes to close the page, they get a...
0
by: Oberon | last post by:
How do I navigate through records using drag 'n' drop controls? I have an example in C# for Windows forms that relies on BindingContext but this is not available for ASP.NET. How do I solve that...
0
by: Husam | last post by:
Hi EveryBody: I got this decleration from msdn documntation which is: object.Navigate( _ url As String, _ _ _ _ )
2
by: Ryan Ramsey | last post by:
I have been chasing this one down for a week and have narrowed it down to a machine issue. I have the following code: webBrowser.Navigate(http://finao.net/post_dkp.php?database=40); Basically...
1
by: aecorzine | last post by:
Hopefully someone can help... I am new to the programming environment. I am attempting to programmatically (through a click event) open a pdf file and go to a specific page within that file so...
5
by: timnels | last post by:
I have a web browser control that I'd like to point at a HTML file in my installation directory. I am doing something like: string path = Path.GetDirectoryName(...
8
by: =?Utf-8?B?Q29kZVJhem9y?= | last post by:
I am hosting a web application within a windows form using MsHtmlHstInterop.dll. I am opening the web browser window using: object flags = 0; object targetFrame = String.Empty; object...
2
by: Tina | last post by:
How can I programmatically navigate a website just as a user would? click on buttons, hyperlinks, etc. I know how to read nodes using XPath but I don't know what classes to use to navigate. I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.