hi guys
i m using MS Access! I have this page "EditProduct.asp", which has 2 boxes which gets filled according to the Product Id i send from previous page.
i Want to existing data in those 2 boxes and when user edit the data, i send the data to same page, update db and then redirect to the previous page.
The problem i m facing is that when i edit the data, one field shows me numbers like "-1" or "0" and the other field just show me the same data as before editing!!
This is the code, need help!!
Thanx
i m using MS Access! I have this page "EditProduct.asp", which has 2 boxes which gets filled according to the Product Id i send from previous page.
i Want to existing data in those 2 boxes and when user edit the data, i send the data to same page, update db and then redirect to the previous page.
The problem i m facing is that when i edit the data, one field shows me numbers like "-1" or "0" and the other field just show me the same data as before editing!!
This is the code, need help!!
Code:
<%
Dim strProdId, rstShow, strShow
Dim strProductID, strProdName, strProdCode, strEdit
'this strProdIs is coming from previous page
strProdId = Request("pid")
If strProdId <> "" then
Set rstShow = Server.CreateObject("ADODB.Recordset")
strShow = "Select * From tblProductMaster Where Product_Id=" & strProdId
rstShow.Open strShow, Conn,adOpenStatic,adLockOptimistic
End If
'These values r coming thru postback of this page
strProductID = Request("ProdId")
strProdName = Request("txtProductName")
strProdCode = Request("txtProductCode")
If strProdName <> "" And strProdCode <> "" Then
strEdit = "Update tblProductMaster Set Product_Name='" & strProdName & "' And Product_Code='" & strProdCode & "' Where Product_Id=" & strProductID
Conn.Execute(strEdit)
Conn.close
Response.Redirect("AddProduct.asp")
End If
%>
<form action="EditProduct.asp" method="post" name="frmProduct" id="frm1">
<input type="hidden" name="ProdId" value="<%=strProdId%>">
<center>
<table border="1" cellspacing="2" cellpadding=2 bordercolor="#505050" width=400>
<TBODY>
<tr>
<th colspan=2 align="middle" bgcolor="#0050b0">
<font color="white" face=Tahoma size=3>Edit Product</font></th>
</tr>
<tr>
<td>
<table border="0" cellspacing="2" cellpadding=2 bordercolor="maroon" width=400>
<TBODY>
<tr>
<td align="right"><br><FONT face=Tahoma size=2>Product Name* : </FONT></td>
<td><br><input name="txtProductName" style="WIDTH: 190px; HEIGHT: 22px" tabIndex=1 value=<%Response.Write(rstShow("Product_Name"))%>></td>
</tr>
<tr>
<td align="right"><FONT face=Tahoma size=2>Product Code* : </FONT></td>
<td><INPUT style="WIDTH: 190px; HEIGHT: 22px" tabIndex=2 name=txtProductCode value=<%Response.Write(rstShow("Product_Code"))%>></td>
</tr>
</form>
<tr>
<td colspan="2" align="middle">
<input type="submit" name="btnSubmit" value="Save" id="cmd1" style="WIDTH: 80px; HEIGHT: 26px" tabIndex=3></td>
</tr></TBODY></TABLE></TD></TR></TBODY></TABLE></CENTER>
<P> </P>
<%
rstShow.Close()
Conn.Close
%>
Thanx



