I tried it again quickly and it works fine using only one connection. When you use connection.Execute() it returns a forward-only read-only cursor, so the connection should still be able to service other calls. I'm pretty sure its just with Jet though, it works ok here on SQL Server.
Back to your first question. Say you want to let people vote in a poll. You have a table called VOTE with a poll_id pointing to the poll and a code for what they voted for, names vote_code. When you write the links to the screen, use querystrings appended to the URL and point them back to the same page:
page filename: poll.asp
Code:
Poll Response Links:
<A HREF="poll.asp?poll_id=1&vote_code=A">Vote for A</A>
<A HREF="poll.asp?poll_id=1&vote_code=B">Vote for B</A>
<A HREF="poll.asp?poll_id=1&vote_code=C">Vote for C</A>
In the header of poll.asp you need to intercept and handle that request. the querystring values are part of a collection hanging off of the Request intrinsic object. This is bad, but it will work:
Code:
<%'local functions
sub SaveVote(conn, poll, vote, userIP)
dim sql
sql = "INSERT INTO VOTE (poll_id, vote_code, user_ip) " & _
"VALUES(" & poll & ", '" & vote & "', '" & userIP & "')"
conn.Execute sql
end sub
'variable declarations
dim connString
dim connection
dim pollID
dim voteCode
dim IP
'grab any incoming data
pollID = Request.QueryString("poll_id")
voteCode = Request.QueryString("vote_code")
IP = Request.ServerVariables("REMOTE_ADDR")
'validate the data. the poll_id is an integer
'and the voteCode is a one character value
if not isNumeric(pollID) then pollID = ""
if len(voteCode) > 1 then voteCode = ""
'if both the poll_id and vote_code are empty then
'redirect to the poll selection page
if pollID = "" and voteCode = "" then
Response.Redirect "poll_list.asp"
Response.End
end if
'open a database connection
connection.Open connString
'if the vote_code is not empty then log the vote
if voteCode <> "" then
SaveVote connection, pollID, voteCode, IP
end if
'get the poll info and render the page
%>