Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with Search and Update data

Status
Not open for further replies.

senadaulay

Programmer
Feb 4, 2004
29
ID
Help Please....Thanks in advance for your help
I Need to Update my data... I create search form first if the user want to update certain data
they only need to enter EmployeeIDthis in SearchUpdate.asp form,then the data list show in ResultUpdate.asp form.and the 3rd form is confirmationUpdate.asp form,
which for tell the data have been updated or the updated is not working.
My search coding is working I dont know where to put the Update code.
I have been trying but still not working and there are no error show either.
this is my code"

SearchUpdate.asp

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
</HEAD>
<BODY>
<FORM METHOD="post" ACTION="ResultUpdate.asp" id=form1 name=form1>
<P><input name="EmployeeID" >&nbsp;<INPUT type="submit" value="Submit" name="B1"></P>
</FORM>
</BODY>
</HTML>

ResultUpdate.asp

<%
Dim varID, varName, varAddress
Dim varPhome, intPostal, varSalary
Dim strsql
Dim Conn
Dim strConnect
Dim rsData

varID = Request.Form ("EmployeeID")
varName = Request.Form ("EmployeeName")
varAddress = Request.Form ("EmployeeAddress")
varPhome = Request.Form ("EmployeePhoneHome")
intPostal = Request.Form ("EmployeePostalCode")
varSalary = Request.Form ("EmployeeSalary")

Set Conn = Server.CreateObject ("ADODB.CONNECTION")
Set rsData = Server.CreateObject ("ADODB.Recordset")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\TblEmploy.mdb"
rsData.Open "Data", Conn
strsql = "Select * from Data "
strsql=strsql & "where EmployeeID=" & varID& ";"
Set rsData = Conn.Execute(strsql)

If Request.Form ("submit1") = "UPDATE" then

strsql = "UPDATE DATA SET " &_
"EmployeeName = '"& varName &"',EmployeeAddress = '"& varAddress &"', " & _
"EmployeePhoneHome = '"& varPhoneHome &"',EmployeePostalCode = '"& varPostalCode &"',EmpployeeSalary = '"& varSalary &"'," &_
"WHERE EmployeeID = '"& varID &"'"
Response.Write strsql
Conn.Execute strsql
Conn.Close
Set Conn = nothing
end if
%>

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
</HEAD>
<BODY>
<FORM ACTION= "ConfirmUpdate.asp" METHOD=post Name=frmConfirm >
<TABLE style="WIDTH: 402px; HEIGHT: 172px" cellSpacing=1 cellPadding=1 width=402
border=1>

<TR><TD><P>EmployeeName</P></TD>
<TD><INPUT type="text" name="EmpName" value="<%=rsData ("EmployeeName")%>" ></TD></TR>
<TR><TD>EmployeeAddress</TD>
<TD><INPUT type="text" name="EmpAddress" value="<%=rsData("EmployeeAddress")%>" ></TD></TR>
<TR><TD>EmployeePhoneHome</TD>
<TD><INPUT type="text" name="EmpPhone" value="<%=rsData("EmployeePhoneHome")%>" ></TD></TR>
<TR><TD>EmployeePostalCode</TD>
<TD><SELECT type="dropdown" name="EmpPostal" value="<%=rsData("EmployeePostalCode")%>" style="WIDTH: 154px" >
<OPTION>1234</OPTION>
<OPTION>2345</OPTION></SELECT></TD></TR>
<TR><TD>EmployeeSalary</TD>
<TD><INPUT type="text" name="EmpSalary" value="<%=rsData("EmployeeSalary")%>" ></TD></TR>

</TABLE></P>
<INPUT id=submit1 style="WIDTH: 85px; HEIGHT: 40px" type=Submit size=28 value=UPDATE name=submit1></P>

</FORM>
</BODY>
</HTML>

any suggestion might help...I really Appreciate
Thanks
 
u have to use the update stmt in the confirmUpdate.asp...

Known is handfull, Unknown is worldfull
 
Actually I have been trying to do it in 2 form, Can I do in 2 Forms?

And I have been doing some changing...could someone tell me whats wrong with my code? thank in advance

searchUpdate.asp
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
</HEAD>
<BODY>
<FORM METHOD="post" ACTION="ResultUpdate.asp" id=form1 name=form1>
<P><input type="text" name="EmpID" value="<%=session("ID")%>" >&nbsp;<INPUT type="submit" value="Submit" name="B1"></P>
</FORM>
</BODY>
</HTML>

ResultUpdate.asp
<%
Dim strsql
Dim Conn
Dim strConnect
Dim rsData

Session("ID") = Request.Form("EmpID")

Set Conn = Server.CreateObject ("ADODB.CONNECTION")
Set rsData = Server.CreateObject ("ADODB.Recordset")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\TblEmploy.mdb"
rsData.Open "Data", Conn
strsql = "Select * from Data "
strsql=strsql & "where EmployeeID=" &session("ID")& ""
Set rsData = Conn.Execute(strsql)

If Request.Form ("submit1") = "UPDATE" then
strsql = "UPDATE Data " &_
"SET EmployeeID= '"&session("ID") &"',EmployeeName= '"&session("SName")&"',EmployeeAddress= '"&session("Address")&"', " & _
"EmployeePhoneHome= '"&session("PhoneHome")&"',EmployeePostalCode= '"&session("PostalCode")&"',EmpployeeSalary= '"&session("Salary")&"'" &_
"WHERE EmployeeID= '" &session("ID")&"'"
Response.Write strsql
Conn.Execute (strsql)
Conn.Close
end if
%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
</HEAD>
<BODY>
<FORM ACTION= "ConfirmUpdate.asp" METHOD=post Name=frmConfirm >
<TABLE style="WIDTH: 402px; HEIGHT: 172px" cellSpacing=1 cellPadding=1 width=402
border=1>
<TR><TD><P>EmployeeID</P></TD>
<TD><INPUT type="text" name="EmpID" value="<%=rsData("EmployeeID")%>" ></TD></TR>
<TR><TD><P>EmployeeName</P></TD>
<TD><INPUT type="text" name="EmpName" value="<%=rsData("EmployeeName")%>" ></TD></TR>
<TR><TD>EmployeeAddress</TD>
<TD><INPUT type="text" name="EmpAddress" value="<%=rsData("EmployeeAddress")%>" ></TD></TR>
<TR><TD>EmployeePhoneHome</TD>
<TD><INPUT type="text" name="EmpPhone" value="<%=rsData("EmployeePhoneHome")%>" ></TD></TR>
<TR><TD>EmployeePostalCode</TD>
<TD><INPUT type="text" name="EmpPostal" value="<%=rsData("EmployeePostalCode")%>" > </TD></TR>
<TR><TD>EmployeeSalary</TD>
<TD><INPUT type="text" name="EmpSalary" value="<%=rsData("EmployeeSalary")%>" ></TD></TR>

</TABLE></P>
<INPUT id=submit1 style="WIDTH: 85px; HEIGHT: 40px" type=Submit size=28 value=UPDATE name=submit1></P>
</FORM>
</BODY>
</HTML>

any help appreciate
thanks
 
u have to do it in two forms, one for displaying the old info, the next form for capturing that info and updating it...

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top