ASP w/ Access DB

Winchester

Diamond Member
Jan 21, 2003
4,965
0
0
I am trying to tie an Access DB into a webpage using regular ASP, not .NET.

Also, how can I make it so that only one record shows up on each page and then by using Next/Previous be able to go back and forth between the other records?

EDIT: Alright, I have gotten pretty far AFAIK. As of now I can sort by letter, last name, etc. I even have the links to go to the member page from the directory, but it is not going to the actual member selected.

This is the code I have on the "main directory" page to link to the individual records:

<a href="odbcmember.asp?Start=0&Offset=15&LastName=<%=RS("LastName")%>"> <%=RS("LastName")%>- <%=RS("FirstName")%>,<%=RS("FamilySpouse")%></a>

When I click on the members Last name it should take me to that member, but it is just taking me to generic member, the first one I created.

 

ncage

Golden Member
Jan 14, 2001
1,608
0
71
I don't knwo if its the same in asp as it is in asp.net. I never really used classic asp thatmuch but if it is you need to check for .IsPostBack. If it is then you don't want to run that code again. Hopefully this helps
 

Zontor

Senior member
Sep 19, 2000
530
0
0
Couple o'thoughts ... I don't use Access so I can't test....you also didn't include the verbose error message(s).

>>Error on line #7:

Where are you closing the connection string when done? Without seeing it I'd say you still have an open connection. Again - I can't test this since I don't run Access.

>>Also, how can I make it so that only one record shows up on each page and then by using >>Next/Previous be able to go back and forth between the other records?

Two answers (out of many):

1] If there aren't a ton of records I'd load them in a Getrows array and move back and forth through the array. This is the best way if bandwidth permits and there aren't a lot of records.

2] Not as nice but ... Use the recordSet methods - more database hits than the first.

There are numerous ways to do this stuff - just two suggestions here.



 

Winchester

Diamond Member
Jan 21, 2003
4,965
0
0
Zontor,

I had someone locally point (My.Conn Closed) out to me this morning. I will try that tonight.

There will probably be ~150 records MAX.
 

KB

Diamond Member
Nov 8, 1999
5,406
389
126
What Zontor said, you need to close your connection.

<%
Recordset.Close
Set Recordset=Nothing
Connection.Close
Set Connection=Nothing
%>
 

Winchester

Diamond Member
Jan 21, 2003
4,965
0
0
KB

I get an error when using your code. Do I put the code after the

<%
RS.MoveNext
WEND%>

Remember, I am using plain ASP not .NET.
 

milehigh

Senior member
Nov 1, 1999
951
0
76
Originally posted by: Winchester
KB

I get an error when using your code. Do I put the code after the

<%
RS.MoveNext
WEND%>

Remember, I am using plain ASP not .NET.

This should work...

<%
rs.MoveNext
Wend
rs.Close
MyConn.Close
set MyConn = Nothing
%>


 

Winchester

Diamond Member
Jan 21, 2003
4,965
0
0
Thanks milehigh, I figured it out after "truly" comparing it. Im still in the learning phase. I am proud of myself for figuring it out on my own though ;)

Im still stuck on as to how I can get only (1) record per page. I know it has to do with the
SQL_query = "SELECT * FROM Friends" piece. Any help?
 

Zontor

Senior member
Sep 19, 2000
530
0
0
Originally posted by: Winchester
Thanks milehigh, I figured it out after "truly" comparing it. Im still in the learning phase. I am proud of myself for figuring it out on my own though ;)

Im still stuck on as to how I can get only (1) record per page. I know it has to do with the
SQL_query = "SELECT * FROM Friends" piece. Any help?

The links I provided earlier should let you do this. Did you read them? Getrows really is your best solution here because you grab all the records in one lump. You can use a bit of Dynamic HTML (Ajax if you wish) to simply update a div content with the results of your forward or backward button.

If you don't want to do the above, let the recordset object handle the work for you.

If you're thinking about a SELECT TOP 1 * FROM Friends this won't work because you can't move back and forward through the friends easily. Yes, you can do this in SQL but if you're learning it won't be nearly as easy as doing what I've described earlier.
 

Winchester

Diamond Member
Jan 21, 2003
4,965
0
0
Zontor,

Ive read the articles, but I need it to have a DSNless connection and from reading those they require DSN.
 

Zontor

Senior member
Sep 19, 2000
530
0
0
Originally posted by: Winchester
Zontor,

Ive read the articles, but I need it to have a DSNless connection and from reading those they require DSN.


The connection string can be independant of the recordSet object - the purpose of the articles is not to cut and paste but to take a concept and mold it to your own use. The techniques work regardless of your connection type - You might want to look at this regarding connection strings.

Good luck!
 

Zontor

Senior member
Sep 19, 2000
530
0
0
Originally posted by: Winchester
Zontor, Look at the updated OP. Im getting closer.


Coolness. That is how you learn - poking and proding. Since I only see a small part of what you're doing I'll give you some generalized advice.

You should have a primary key in your database (an identity field - in its simplest form it is a number that is incremented by 1 each time you add a person). You want each member to have a unique number that will never be repeated.

Once you've drilled down to the person you want info about your link should contain that persons unique identity number.

Suppose you've found the person you want to know about - instead of passing something like rs("last_name") & rs("first_name") via querystring or via a form to an action page -- you'd pass rs("identity_field")

Your action page SQL would pull that user by using

SELECT * FROM FRIENDS WHERE identify_field = " & Request.Querystring("identity_field") & ";"

then you're specifying exactly the user you want to see and removing all ambiguity.


 

Winchester

Diamond Member
Jan 21, 2003
4,965
0
0
Zontor, I have been searching on how to get it to assign an ID in Access. Ive drawn a blank, since I usally can do it. To many things on my mind.