Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
database and loop syntax
Old 05-02-2004, 03:06 AM database and loop syntax
techwench's Avatar
Code Monkey

Posts: 1,449
Name: Danalyn
Location: Dallas, TX
Trades: 0
Okay...so I have to learn ASP (not .NET) for work...I'm doing it...slowly...It's different, I gotta say. I setup IIS on my local machine and got an access database setup for testing. Have to use Access for work because we don't have SQL Server installed (yet).

Anyway, I'm trying to figure out what the syntax would be for a couple of while loops in a relational database.

I have the following tables setup in my database:

Code:
+------------------------------+
| category                     |
+------------------------------+
| cat_id      category         |
+-----------+------------------+
| 1         | PC Software      |
+-----------+------------------+
| 2         | Mac Software     |
+------------------------------+

+---------------------------------------------+
| software                                    |
+---------------------------------------------+
| id      cat_id    title              notes  |
+---------------------------------------------+
| 1     | 1       | Adobe Photosop   | notes  |
+---------------------------------------------+
| 2     | 1       | Adobe Pagemaker  | notes  |
+---------------------------------------------+
| 3     | 1       | Quark Xpress     | notes  |
+---------------------------------------------+
| 4     | 2       | OS X             | notes  |
+---------------------------------------------+

Now, what I need to figure out is how to display this. I need something like:


Code:
While Category
    Print Category Name

    While Category ID
        Print Software Title
        Print Software Notes
    End While

End While
Syntax is a little different from what I'm used to, and I haven't quite gotten used to it yet... I got myself a SAMS book, and got a bunch of new bookmarks, but all I've managed is headaches so far. I'd appreciate any pointers.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Last edited by techwench; 05-02-2004 at 03:47 AM..
techwench is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-05-2004, 03:08 PM
techwench's Avatar
Code Monkey

Posts: 1,449
Name: Danalyn
Location: Dallas, TX
Trades: 0
Nevermind. Figured it out.


Code:
<%
Response.Expires = 0

Dim objConn, objRS, strQuery
Dim strConnection

Set objConn = Server.CreateObject("ADODB.Connection")
MdbFilePath = Server.MapPath("db1.mdb")
strConnection = "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & MdbFilePath 
objConn.Open strConnection

strQuery = "SELECT * FROM software, category WHERE software.cat_id=category.cat_id ORDER BY category.category, software.title ASC"

Set objRS = objConn.Execute(strQuery)
%>


<TABLE WIDTH="500" ALIGN="center" CELLSPACING="0" CELLPADDING="3" BORDER="0">
 

<%
While not objRS.EOF
	currentID=objRS("category")
	If oldID = currentID Then
%>

		<TR><TD WIDTH="40">&nbsp;</TD><TD><LI><%=objRS("title")%></LI></TD></TR>

<%	Else %>

		<TR><TD colspan="2"><H2><%=objRS("category")%></H2></TD></TR>

<%		
	End If
	oldID=currentID	
	objRS.MoveNext
Wend
%>

</TABLE>

<%
objRS.Close
objConn.Close
Set objRS = Nothing
Set objConn = Nothing
%>
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
techwench is offline
Reply With Quote
View Public Profile
 
Old 06-01-2004, 03:53 PM
Novice Talker

Posts: 14
Trades: 0
It took you three days to work it out?
jonnyfb is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to database and loop syntax
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.20613 seconds with 12 queries