PDA

View Full Version : Dreamweaver MX: ASP.NET creating art gallery


sssaudddahmed
Mar 31, 2005, 12:51 AM
I am creating a web art gallery. The problem I am having at the moment is that I want to link members on the site to their gallery page.

I have a page with members name on them. I want to link those names to a single gallery page. Depedning on what name I pressed on, I want the gallery page to change to display that members art.

Furthermore at the top of the page there will be another table that will display the member profile and name according to the name that was pressed.

I am using DWMX, IIS, ASP.NET, MS Access. I have linked to the page using OLEDB and I have two datasets one for members details and the second for picture details.

Please can someone tell me how this can be done.

LTheobald
Mar 31, 2005, 02:30 AM
Haven't touched ASP for years, so I can't be detailed but here's what you need to do.

On the page with all the members names, you want the link to the gallery page to be something like <a href="gallery.asp?name=memberID">. To do this you'll need a loop that loops through each member's details, creating a link using their name/id/whatever you are using as a primary key on the members table.

Then on the gallery page you will need to retrieve the value of memberID from the querystring. Can't remember the ASP syntax to do this :(

Then use this value to peform an SQL query retrieving the data just for that member. I.e. for the table at the top with the member details - "Select * from members where memberID = '"+ memberID +"';"

That's basically how you do it. Hopefully some of the other experts can fill in the syntax gaps. If not, I'll do it when I get home tonight (if I remember).

sssaudddahmed
Apr 1, 2005, 12:46 AM
Sorry for the late peply.

I understand what you mean by using the member number in otder to relate the member list to the galley. But since I am new to ASP.NET could be describe in details what synataxs I should use and where in the script page I should put it.

Sorry for the inconvienence.

LTheobald
Apr 7, 2005, 04:58 AM
Sorry it's taken me a long time to reply. OK, here's my understanding of how it would be done (remember I've not done ASP for years so it may be slightly incorrect)

First Page - Shows member names



<html>
<head>
<title>Members</title>
</head>

<body>
<%

' Create Connection and Recordset objects
Set Conn = Server.CreateObject("ADODB.Connection")
Set Rs = Server.CreateObject("ADODB.RecordSet")

' Open the connection to the ODBC source, in this case
' the Access database
Conn.Open "your_ODBC_source"

' Now, create the SQL statement
SQL = "SELECT id, name FROM tbl_member"

' Execute the SQL statement to get a recordset
Set Rs = Conn.Execute(SQL)

' While records remain in the record set
Do While NOT Rs.EOF
' Print out a link for the current member
Response.Write("<a href=""gallery.asp?id="& Rs.Fields("id").value &""">"& Rs.Fields("id").value &"</a>")

' Move to the next record
Rs.MoveNext
Loop

' Tidy Up
Rs.Close
Set Rs = Nothing
Conn.Close
Set Conn = Nothing

%>
</body>
</html>


Page 2 - Gallery


<html>
<head>
<title>Members</title>
</head>

<body>
<%

' Retrieve the user's ID. You'll want this to retrieve the users data
userID = Request.QueryString("id")

' Create Connection and Recordset objects
Set Conn = Server.CreateObject("ADODB.Connection")
Set Rs = Server.CreateObject("ADODB.RecordSet")

' Open the connection to the ODBC source, in this case
' the Access database
Conn.Open "your_ODBC_source"

' Now, create the SQL statement
SQL = "SELECT * FROM tbl_gallery WHERE memberID = "& userID

' Execute the SQL statement to get a recordset
Set Rs = Conn.Execute(SQL)

' While records remain in the record set
Do While NOT Rs.EOF
'
' Do whatever you want with the data here!
'

' Move to the next record
Rs.MoveNext
Loop

' Tidy Up
Rs.Close
Set Rs = Nothing
Conn.Close
Set Conn = Nothing

%>
</body>
</html>



This was all pieced together off another website so sorry if it's inconsistent etc.

sssaudddahmed
Apr 16, 2005, 11:13 PM
Thanks for the reply. I tried using your code for my website and it worked. Thanks