web 2.0

How to use ASP & Oracle Edit/Update Multiple Rows Record

How to use ASP & Oracle Edit/Update Multiple Rows Record This is tutorial asp developers how to using ASP edit/update multiple record on oracle table.

ShotDev Focus:
- ASP & Oracle edit/update multiple record.

Example

asp_oracle_edit_multiple.asp


<% Option Explicit %>
<html>
<head>
<title>ShotDev.Com Tutorial</title>
</head>
<body>
<%
Dim Conn,strSQL,objRec,objExec,i
Set Conn = Server.Createobject("ADODB.Connection")
Conn.Open "Driver={Oracle in OraHome92};DBQ=TCDB;UID=myuser;PWD=mypassword;"

'*** Update Condition ***'
If Request.QueryString("Action") = "Save" Then
ForĀ  i = 1 To Request.Form("hdnLine")
strSQL = "UPDATE CUSTOMER SET "
strSQL = strSQL &"CUSTOMERID = '"&Request.Form("txtCustomerID" & i)&"' "
strSQL = strSQL &",NAME = '"&Request.Form("txtName" & i)&"' "
strSQL = strSQL &",EMAIL = '"&Request.Form("txtEmail" & i)&"' "
strSQL = strSQL &",COUNTRYCODE = '"&Request.Form("txtCountryCode" & i)&"' "
strSQL = strSQL &",BUDGET = '"&Request.Form("txtBudget" & i)&"' "
strSQL = strSQL &",USED = '"&Request.Form("txtUsed" & i)&"' "
strSQL = strSQL &"WHERE CUSTOMERID = '"&Request.Form("hdnCustomerID" & i)&"' "
Set objExec = Conn.Execute(strSQL)
Next
End IF

strSQL = "SELECT * FROM CUSTOMERĀ  "
Set objRec = Server.CreateObject("ADODB.Recordset")
objRec.Open strSQL, Conn, 1,3
%>
<form name="frmMain" method="post" action="asp_oracle_edit_multiple.asp?Action=Save">
<table width="600" border="1">
<tr>
<th width="91"> <div align="center">CustomerID </div></th>
<th width="98"> <div align="center">Name </div></th>
<th width="198"> <div align="center">Email </div></th>
<th width="97"> <div align="center">CountryCode </div></th>
<th width="59"> <div align="center">Budget </div></th>
<th width="71"> <div align="center">Used </div></th>
</tr>
<%
i = 0
While Not objRec.EOF
i = i + 1
%>
<tr>
<td><div align="center">
<input type="hidden" name="hdnCustomerID<%=i%>" size="5" value="<%=objRec.Fields("CUSTOMERID").Value%>">
<input type="text" name="txtCustomerID<%=i%>" size="5" value="<%=objRec.Fields("CUSTOMERID").Value%>">
</div></td>
<td><input type="text" name="txtName<%=i%>" size="20" value="<%=objRec.Fields("NAME").Value%>"></td>
<td><input type="text" name="txtEmail<%=i%>" size="20" value="<%=objRec.Fields("EMAIL").Value%>"></td>
<td><div align="center"><input type="text" name="txtCountryCode<%=i%>" size="2" value="<%=objRec.Fields("COUNTRYCODE").Value%>"></div></td>
<td align="right"><input type="text" name="txtBudget<%=i%>" size="5" value="<%=objRec.Fields("BUDGET").Value%>"></td>
<td align="right"><input type="text" name="txtUsed<%=i%>" size="5" value="<%=objRec.Fields("USED").Value%>"></td>
</tr>
<%
objRec.MoveNext
Wend
%>
</table>
<input type="submit" name="submit" value="submit">
<input type="hidden" name="hdnLine" value="<%=i%>">
</form>
<%
objRec.Close()
Conn.Close()
Set objRec = Nothing
Set Conn = Nothing
%>
</body>
</html>

Create a asp file and save to path root-path/myasp/

Run
http://localhost/myasp/asp_oracle_edit_multiple.asp

Screenshot

ASP & Oracle (Edit/Update Multiple Record)

.
.
.
Download this script.
Download

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (2 votes, average: 5.50 out of 10)
Loading ... Loading ...

Leave a Reply

You must be logged in to post a comment.