SofaKing
05-01-2011, 10:48 PM
:confused: I am a university student trying to complete my independent study which was to build a simple dynamic web page. I am using ASP, ADO, and SQL to do this. There are some bugs that I just can't figure and their driving me crazy. Basically, the form (.html)page takes 3 input values: userName, noteSub, and myNote. These are then passed to the (.asp)page to insert into the DB. My first problem is that only the userName is being inserted into the DB; noteSub and myNote are not. Below is the code for the .html form page and .asp page that inserts the values. I also want to be able to allow users to display their specific notes via query.
*addnote.html:
<form action="addnote.asp" method="post" name="noteIN" id="noteIN">
<table align="left">
<tr>
<td>Username:</td>
<td><input name="userName"></td>
</tr><tr>
<td>Subject :</td>
<td><input name="noteSubject" size="50"></td>
</tr><tr>
<td>Note :</td>
<td><textarea name="note" cols="85" rows="15"></textarea></td>
</tr>
</table>
<center>
<input name="addNote" type="submit" id="addNote" value="Add Note">
<input name="cancelREG" type="reset" id="cancelREG" value="Cancel">
</center>
</form>
</div>
*addnote.asp
<successtemplate>
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/webdata/version2/note.mdb"
sql="INSERT INTO notes (userName,noteSub,"
sql=sql & "myNote)"
sql=sql & " VALUES "
sql=sql & "('" & Request.Form("userName") & "',"
sql=sql & "'" & Request.Form("noteSub") & "',"
sql=sql & "'" & Request.Form("myNote") & "')"
on error resume next
conn.Execute sql,recaffected
if err<>0 then
Response.Write("No update permissions!")
else
Response.Write("<h3>" & recaffected & " record added</h3>")
end if
conn.close
%>
</successtemplate>
When submitted, it displays that 1 record has been added, but noteSub and myNote are not!?
Then i want to be able to have users input their username and display their specific notes. This is where my biggest headache is. I have a form page
*shownoteID.html:
<form action="display.asp" method="post" id="retrieve">
<table align="center">
<tr>
<td>Username :</td>
<td><input name="userName"></td>
</tr>
</table>
<br /><br />
<center>
<input name="getNote" type="submit" id="getNote" value="Get Notes!">
<input name="cancelQry" type="reset" id="cancelQry" value="Cancel">
</center>
</form>
Then, the query is really where im lost. I have an .asp page:
*display.asp:
<successtemplate>
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/webdata/version2/note.mdb"
set rs=Server.CreateObject("ADODB.Recordset")
rs.open "SELECT * FROM note WHERE userName='" & Request.Form("userName") & "'",conn
do until rs.EOF
for each x in rs.Fields
Response.Write(x.name)
Response.Write(" = ")
Response.Write(x.value & "<br />")
next
Response.Write("<br />")
rs.MoveNext
loop
rs.close
conn.close
%>
This is supposed to display the specific users notes. Any suggestions on what I am doing wrong?!! I cant seem to figure this out!!
I want to pass the userName value to the ADO SQL clause so that it will only display the users notes.
HELP!
*addnote.html:
<form action="addnote.asp" method="post" name="noteIN" id="noteIN">
<table align="left">
<tr>
<td>Username:</td>
<td><input name="userName"></td>
</tr><tr>
<td>Subject :</td>
<td><input name="noteSubject" size="50"></td>
</tr><tr>
<td>Note :</td>
<td><textarea name="note" cols="85" rows="15"></textarea></td>
</tr>
</table>
<center>
<input name="addNote" type="submit" id="addNote" value="Add Note">
<input name="cancelREG" type="reset" id="cancelREG" value="Cancel">
</center>
</form>
</div>
*addnote.asp
<successtemplate>
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/webdata/version2/note.mdb"
sql="INSERT INTO notes (userName,noteSub,"
sql=sql & "myNote)"
sql=sql & " VALUES "
sql=sql & "('" & Request.Form("userName") & "',"
sql=sql & "'" & Request.Form("noteSub") & "',"
sql=sql & "'" & Request.Form("myNote") & "')"
on error resume next
conn.Execute sql,recaffected
if err<>0 then
Response.Write("No update permissions!")
else
Response.Write("<h3>" & recaffected & " record added</h3>")
end if
conn.close
%>
</successtemplate>
When submitted, it displays that 1 record has been added, but noteSub and myNote are not!?
Then i want to be able to have users input their username and display their specific notes. This is where my biggest headache is. I have a form page
*shownoteID.html:
<form action="display.asp" method="post" id="retrieve">
<table align="center">
<tr>
<td>Username :</td>
<td><input name="userName"></td>
</tr>
</table>
<br /><br />
<center>
<input name="getNote" type="submit" id="getNote" value="Get Notes!">
<input name="cancelQry" type="reset" id="cancelQry" value="Cancel">
</center>
</form>
Then, the query is really where im lost. I have an .asp page:
*display.asp:
<successtemplate>
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/webdata/version2/note.mdb"
set rs=Server.CreateObject("ADODB.Recordset")
rs.open "SELECT * FROM note WHERE userName='" & Request.Form("userName") & "'",conn
do until rs.EOF
for each x in rs.Fields
Response.Write(x.name)
Response.Write(" = ")
Response.Write(x.value & "<br />")
next
Response.Write("<br />")
rs.MoveNext
loop
rs.close
conn.close
%>
This is supposed to display the specific users notes. Any suggestions on what I am doing wrong?!! I cant seem to figure this out!!
I want to pass the userName value to the ADO SQL clause so that it will only display the users notes.
HELP!