Hello Everyone.
I'm two weeks old to ASP and doing a little project to learn.
My challenge is that I need to retrieve some information from a database. This information will be displayed inside text boxes.
These text boxes will be within a form where the user can edit the information and click a "submit" button to update.
The form's action is back to itself (action="update.asp"), so that you will see the changes that you have made and can make more if necessary.
The form pulls the database data well enough, but when I change text in the textboxes and hit submit, nothing is entered and thus the values entered into the database are "null".
The Database has alot of columns, so, I'll abbreviate the code, but let me know if you need more and thanks in advance to the kind and wise soul(s)who can help.
I'm two weeks old to ASP and doing a little project to learn.
My challenge is that I need to retrieve some information from a database. This information will be displayed inside text boxes.
These text boxes will be within a form where the user can edit the information and click a "submit" button to update.
The form's action is back to itself (action="update.asp"), so that you will see the changes that you have made and can make more if necessary.
The form pulls the database data well enough, but when I change text in the textboxes and hit submit, nothing is entered and thus the values entered into the database are "null".
The Database has alot of columns, so, I'll abbreviate the code, but let me know if you need more and thanks in advance to the kind and wise soul(s)who can help.
Code:
<%
'This is the connection to the SQL Database.
Dim CONNECTIONSTRING
CONNECTIONSTRING = "PROVIDER=SQLOLEDB;DATABASE=Test;DATA SOURCE=MYPC;Connect Timeout = 120;Extended Properties=""Trusted_Connection=Yes"""
Set SQLCONNECTION = Server.CreateObject("ADODB.Connection")
SQLCONNECTION.Open(CONNECTIONSTRING)
'The Session Objects are generated after login and used to specify
'users so that the correct record can be altered
DIM getinfo
displaydbinfo = "SELECT * FROM Persons WHERE (MailAddress = '"&Session("id")&"') AND (Password = '"&Session("pass")&"')"
Set getinfo=SQLCONNECTION.execute(displaydbinfo)
%>
<form action="updatetest.asp" method="post">
<table border="0" align="left" width=700>
<%
'Here is where I start the loop to get results from the recordset.
'Do I really NEED to use the loop since I know that there will only
'be one result?
DO while not getinfo.eof
%>
<%
'Here's the problem...I set the name of the textbox to be Salutitle,
'the displayed value should be whatever is pulled out of the database
' with the recordset which works well enough.
%>
<tr>
<td align="left"><b>Salutation:</b></td>
<td align="left">
<input type="text" name="SaluTitle" value="<%=getinfo("SaluTitle")%>">
<%
'The SaluTitle variable was global but I changed it and created the
'variable within the loop in case the "Request.Form("SaluTitle")"
'variables generated in the recordset were local to the loop.
'Response.Write(whatever) is just my way of trying to see what's
'going on.
Dim SaluTitle
SaluTitle=Request.Form("SaluTitle")
Response.Write(SaluTitle)
%>
</td>
</tr>
<%'Many more rows and columns following the same format above%>
<%
'This is the beginning of the UPDATE section which will pull the
'inserted values and update the database with the new values. Why
'doesn't it work?
DIM updatedbinfo
updatedbinfo = "Update Persons SET CellPhoneNumber = '"&CellPhoneNumber&"', Department = '"&Department&"', FirstName = '"&FirstName&"', JobTitle = '"&JobTitle&"', MailAddress = '"&MailAddress&"', LastName = '"&LastName&"' , Location = '"&Location&"', Manager = '"&Manager&"', MiddleInitial = '"&MiddleInitial&"', OfficeFAXPhoneNumber = '"&OfficeFAXPhoneNumber&"', OfficePhoneNumber = '"&OfficePhoneNumber&"', PagerPhoneNumber = '"&PagerPhoneNumber&"', AssistantDescription = '"&AssistantDescription&"', Assistant = '"&Assistant&"', SaluTitle = '"&SaluTitle&"', Password = '"&Password&"' WHERE (MailAddress = '"&Session("id")&"') AND (Password = '"&Session("pass")&"')"
Set updateinfo=SQLCONNECTION.execute(updatedbinfo)
'Continuing the loop and moving to the next recordset (that isn't there)
getinfo.movenext
LOOP
%>
</table>
</form>