I'm pulling my hair out. Been working 1 solid week on this. Can anyone help?
I have an access database. ASP. I want to allow visitors to edit changes to entries they previously made. No password necessary. If visitor types in his or her name, want to be able to match the name typed in with names already found in the database, and pull up a list of all those names/records to allow person to edit.
Database table (named Calendar) looks like this:
ID SUBJECT MESSAGE DAY MONTH YEAR ADDEDBY DATEADDED
1 Picnic Fun Outing 12 1 2003 John Doe 12/22/02
2 Circus Cirque du 13 1 2003 Frank York 12/26/02
3 Football Kings vs. 10 2 2003 John Doe 1/3/03
4 Movie Triple XXX 22 2 2003 Mary Smith 1/5/03
Want to be able to retrieve all records under ADDEDBY by John Doe so that he can edit anything he's already added.
Have tried MANY variations of SELECT.
None worked. Is there something about my connection that makes the database retrieval a problem????
Here's my code:
******************
'Create and open connection
set db_conn = Server.CreateObject("ADODB.Connection")
db_conn.Provider = "Microsoft.Jet.OLEDB.4.0"
db_conn.Open Server.Mappath("/dbases/users.mdb")
'Create and open recordset object
Set objRecordset = Server.CreateObject("ADODB.Recordset")
objRecordset.Open "calendar", db_conn, adOpenStatic, adLockPessimistic, adCmdTable
'get the name entered by visitor in referring page
Trim(Request.Form("fname"))
'write the name to top of form to make sure name captured
'(by the way, the name is being written to top of page)
Response.Write(Request.Form("fname"))
'create variable to hold the name
addedby=request.form("fname")
'query the database
sql = "SELECT * FROM [Calendar] WHERE AddedBy = "AddedBy"
'if the name entered does not match any name in the ADDEDBY column,
'tell visitor cannot edit unless has previously entered something
%>
<table border="1" width="100%">
<tr bgcolor="#b0c4de">
<%
'display the database listing for editing
'this works fine, but it retrieves ALL of the records, instead of the ones
'that match the name of the visitor. I don't want visitors to be able to
'edit anyone else's entries
for each x in objRecordset.Fields
response.write("<th>" & ucase(x.name) & "</th>")
next
%>
</tr>
<%do until objRecordset.EOF%>
<tr bgcolor="#f0f0f0">
<form method="post" action="db_edit.asp" target="_blank">
<%
for each x in objRecordset.Fields
if x.name="ID" AND x.name="AddedBy" then%>
<td><input type="submit" name="ID" value="<%=x.value%>"></td>
<%else%>
<td><%Response.Write(x.value)%> </td>
<%end if
next
%>
</form>
<%objRecordset.MoveNext%>
</tr>
<%
loop
objRecordset.close
set objRecordset=nothing
db_conn.close
set db_conn=nothing
*********************
Thanks in advance for any help you can give.
(Might be simple to you, but it's got me going in circles!!)