Forums
This topic is locked
update multiple records by selecting the checkbox
Posted 06 Nov 2007 12:28:52
1
has voted
06 Nov 2007 12:28:52 aspnewasp aspnewasp posted:
I am trying to update records by selecting the checkboxes but not able to do. I have retrieved records from the database and have added checkboxes to each record. now when i select the checkbox that particular record has to be updated. but its not workingCan anyone help me on this plzzzzz
Replies
Replied 06 Nov 2007 22:24:17
06 Nov 2007 22:24:17 dave blohm replied:
can you show me what youre talking about?
- Doc
Progress is made by the discontent.
- Doc
Progress is made by the discontent.
Replied 07 Nov 2007 06:42:48
07 Nov 2007 06:42:48 aspnewasp aspnewasp replied:
I have retrieved records into asp form and each record has a check box along with it. there is a field in database as docrecieved with null value. when i select the check box in the form that particular record has to be updated and docrecieved field should take a value as yes. but i m not able to do it below is the code plz tell me where am i going wrong.
testupdate.asp
<html>
<head>
<title>Searching Users </title>
</head>
<body bgcolor="white">
<center>
<br>
<font color="Red" face="Monotype Corsiva" size="7"><b><i>test update</i></b></font>
</center>
<%
Dim Conn
Dim SQLQuery
Dim rs
Dim docrecieved
dim recordid
docrecieved=request.form("docrecieved"
recordid=request.form("recordid"
'Creating connection Object
set Conn=server.createobject("ADODB.Connection"
'Creating Recordset Object
'Initialising Provider String
connStr = "Driver={SQL Server};" & _
"Server=;" & _
"Database=record;" & _
"Uid=sa;" & _
"Pwd=password;"
Conn.open connStr
set rs = Server.CreateObject("ADODB.Recordset"
rs.open "select * from scandoc",Conn
%>
<form mehtod="post" action="updatetst.asp">
<a href="userdata.asp"><font color=red face=Monotype Corsiva size="4"><b>User Home</a></font></a>
<table width="50%" border="0" align="center" cellpadding="3" cellspacing="2">
<tr bgcolor="#69AFA5">
<td> <strong><font size="2" face="Arial, Helvetica, sans-serif">location </font>
</strong> <div align="center"></div></td>
<td><strong><font size="2" face="Arial, Helvetica, sans-serif">partner</font></strong></td>
<td><strong><font size="2" face="Arial, Helvetica, sans-serif">product</font></strong></td>
<td><strong><font size="2" face="Arial, Helvetica, sans-serif">status</font></strong></td>
<td><strong><font size="2" face="Arial, Helvetica, sans-serif">applicant name</font></strong></td>
<td><strong><font size="2" face="Arial, Helvetica, sans-serif">email id</font></strong></td>
<td><strong><font size="2" face="Arial, Helvetica, sans-serif">doc recieved</font></strong></td>
</tr>
<% while not rs.eof %>
<tr bgcolor="#AAD2CC">
<td><%=rs("location"%></td>
<td><%=rs("partner"%></td>
<td><%=rs("product"%></td>
<td><%=rs("status"%></td>
<td><%=rs("applicantname"%></td>
<td><%=rs("emailid"%></td>
<td><input type ="checkbox" name="checks" value="<%=rs("recordid"%>">
</tr>
<% rs.movenext
wend
%>
</table>
<p align="right"><font face="Verdana" color="#FFFFFF">
<input type="submit" value=" update"></font></td>
</body>
</html>
updatetst.asp
<htmL>
<head>
<title> record updated</title>
</head>
<body bgcolor=white>
<center>
<br>
<font color="blue" face="Monotype Corsiva" size="7"><b><i>record update </i></b></font>
</center>
<%
Dim Conn
Dim SQLQuery
Dim rs
Dim recordid
Dim docrecieved
dim strdocrecieved
recordid =request.form("recordid"
strdocrecieved = request.form("checks"
if (strdocrecieved="" then
response.write("you didnot select any record"
else
'Creating connection Object
set Conn=server.createobject("ADODB.Connection"
'Creating Recordset Object
'Initialising Provider String
connStr = "Driver={SQL Server};" & _
"Server=;" & _
"Database=record;" & _
"Uid=sa;" & _
"Pwd=password;"
Conn.open connStr
set rs = Server.CreateObject("ADODB.Recordset"
SQLQuery="update scandoc set checks='"& strdocrecieved &"' where recordid in ("&recordid&""
rs=Conn.Execute(SQLQuery)
response.write "records are updated"
end if
%>
</html>
</head>
testupdate.asp
<html>
<head>
<title>Searching Users </title>
</head>
<body bgcolor="white">
<center>
<br>
<font color="Red" face="Monotype Corsiva" size="7"><b><i>test update</i></b></font>
</center>
<%
Dim Conn
Dim SQLQuery
Dim rs
Dim docrecieved
dim recordid
docrecieved=request.form("docrecieved"
recordid=request.form("recordid"
'Creating connection Object
set Conn=server.createobject("ADODB.Connection"
'Creating Recordset Object
'Initialising Provider String
connStr = "Driver={SQL Server};" & _
"Server=;" & _
"Database=record;" & _
"Uid=sa;" & _
"Pwd=password;"
Conn.open connStr
set rs = Server.CreateObject("ADODB.Recordset"
rs.open "select * from scandoc",Conn
%>
<form mehtod="post" action="updatetst.asp">
<a href="userdata.asp"><font color=red face=Monotype Corsiva size="4"><b>User Home</a></font></a>
<table width="50%" border="0" align="center" cellpadding="3" cellspacing="2">
<tr bgcolor="#69AFA5">
<td> <strong><font size="2" face="Arial, Helvetica, sans-serif">location </font>
</strong> <div align="center"></div></td>
<td><strong><font size="2" face="Arial, Helvetica, sans-serif">partner</font></strong></td>
<td><strong><font size="2" face="Arial, Helvetica, sans-serif">product</font></strong></td>
<td><strong><font size="2" face="Arial, Helvetica, sans-serif">status</font></strong></td>
<td><strong><font size="2" face="Arial, Helvetica, sans-serif">applicant name</font></strong></td>
<td><strong><font size="2" face="Arial, Helvetica, sans-serif">email id</font></strong></td>
<td><strong><font size="2" face="Arial, Helvetica, sans-serif">doc recieved</font></strong></td>
</tr>
<% while not rs.eof %>
<tr bgcolor="#AAD2CC">
<td><%=rs("location"%></td>
<td><%=rs("partner"%></td>
<td><%=rs("product"%></td>
<td><%=rs("status"%></td>
<td><%=rs("applicantname"%></td>
<td><%=rs("emailid"%></td>
<td><input type ="checkbox" name="checks" value="<%=rs("recordid"%>">
</tr>
<% rs.movenext
wend
%>
</table>
<p align="right"><font face="Verdana" color="#FFFFFF">
<input type="submit" value=" update"></font></td>
</body>
</html>
updatetst.asp
<htmL>
<head>
<title> record updated</title>
</head>
<body bgcolor=white>
<center>
<br>
<font color="blue" face="Monotype Corsiva" size="7"><b><i>record update </i></b></font>
</center>
<%
Dim Conn
Dim SQLQuery
Dim rs
Dim recordid
Dim docrecieved
dim strdocrecieved
recordid =request.form("recordid"
strdocrecieved = request.form("checks"
if (strdocrecieved="" then
response.write("you didnot select any record"
else
'Creating connection Object
set Conn=server.createobject("ADODB.Connection"
'Creating Recordset Object
'Initialising Provider String
connStr = "Driver={SQL Server};" & _
"Server=;" & _
"Database=record;" & _
"Uid=sa;" & _
"Pwd=password;"
Conn.open connStr
set rs = Server.CreateObject("ADODB.Recordset"
SQLQuery="update scandoc set checks='"& strdocrecieved &"' where recordid in ("&recordid&""
rs=Conn.Execute(SQLQuery)
response.write "records are updated"
end if
%>
</html>
</head>