473,666 Members | 2,258 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

modify multipale rows in database

idsanjeev
241 New Member
hello
i want to modify multiple rows in database with select option i am using R.update but it can update only one record in database but i wants to more then one record is modify after submit so what code i have to use i am using
Expand|Select|Wrap|Line Numbers
  1. <% 
  2.   If Not IsEmpty(Request.Form("submit")) then
  3.   vopenflg = Request.Form("vopenflg")
  4.   vopenflg=trim(vopenflg)
  5.   conn.close
  6.   conn.Mode = adModeReadWrite
  7.   conn.open
  8.   R1.open "Select open_flg from topmaster ", conn, adOpenStatic, adLockOptimistic, adCmdText
  9.   R1("open_flg")= vopenflg
  10.   R1.update
  11.   R1.Close
  12.   end if
  13. %>
Nov 2 '07 #1
20 2339
jhardman
3,406 Recognized Expert Specialist
Put your update statement within a loop. Youcan loop through various rows of your recordset using the r1.movenext method, then modify that row as desired. Let me know if this helps.

Jared

PS. Your code belongs in code tags like this: [code=asp]'code goes here[/code]
Nov 2 '07 #2
idsanjeev
241 New Member
hello,
Jared
when i am using this code it is not report any error or nither update any row
so where is the problems
Expand|Select|Wrap|Line Numbers
  1. 'code goes here
  2. <%   conn.close
  3.   If Not IsEmpty(Request.Form("submit")) then
  4.   vopenflg = Request.Form("vopenflg")
  5.   vopenflg=trim(vopenflg)
  6.   conn.Mode = adModeReadWrite
  7.   conn.open
  8.   R1.open "Select open_flg from topmaster ", conn, adOpenStatic, adLockOptimistic, adCmdText
  9.  while R1.eof
  10.   R1("open_flg")= vopenflg
  11.   R1.update
  12.   R1.movenext
  13.   R1.Close
  14.   wend    
  15.   end if
  16. %>
Nov 3 '07 #3
idsanjeev
241 New Member
hello,
Jared
when i am using this code it is not report any error or nither update any row
so where is the problems
another code is
Expand|Select|Wrap|Line Numbers
  1.  'code goes here
  2. <%  do until not  R1.eof
  3.   R1("open_flg")= vopenflg
  4.   R1.update
  5.   R1.movenext
  6.   loop
  7.   R1.Close
  8.   end if
  9.  
and by using the code do whiel not R1.eof instead of do until not R1.eof
error is multiple oledb
so what is
Nov 3 '07 #4
jhardman
3,406 Recognized Expert Specialist
code should be "do until R1.eof...loop" or "while not R1.eof... wend" or some variation of this.

Jared
Nov 3 '07 #5
idsanjeev
241 New Member
hello plz help in updation of data with multiple row. this code is my last modified code which is using today interchange the code but i found some error this code isn't generate any error but modification or updation is not done . os plz see again here
Expand|Select|Wrap|Line Numbers
  1.  R1.open "Select open_flg from topmaster ", conn, adOpenStatic, adLockOptimistic, adCmdText
  2.      Do While Not R1.EOF
  3.      vopenflg=R1("open_flg")
  4.      R1.update
  5.        R1.MoveNext
  6.        loop
  7.      R1.Close
Nov 5 '07 #6
idsanjeev
241 New Member
i am using this code then it update all records from table i am using pagingnation and show one record on page plz help in updae to selected rows only thaks
Expand|Select|Wrap|Line Numbers
  1.  <%conn.close
  2.   If Not IsEmpty(Request.Form("submit")) then
  3.   vopenflg = Request.Form("vopenflg")
  4.   vopenflg=trim(vopenflg)
  5.   conn.Mode = adModeReadWrite
  6.   conn.open
  7.   R1.open "Select open_flg from topmaster ", conn, adOpenStatic, adLockOptimistic, adCmdText
  8.   R1("open_flg")=vopenflg
  9.   do while not R1.eof
  10.   R1.moveNext
  11.   loop
  12.   R1.update
  13.   R1.Close
  14.   conn.close
  15.   end if
  16. %>
Nov 6 '07 #7
jhardman
3,406 Recognized Expert Specialist
idsanjeev,

Since I am bilingual, I understand the difficulty you face in trying to express yourself in a foreign language. Please understand that you have not given enough information for me to answer the question fully. There are many possible ways in which someone may try to "update a database", and your question does not specify what you mean.

I assume that your user will see a table of data which approximates your database. He performs some action like clicking on a button or toggling a checkbox to indicate which records need to be modified. It looks from your question that the user sees a long list of records and next to each one there is a checkbox. He toggles the boxes he would like to update, then clicks a "submit" button. Am I right so far?

Please explain how the form is set up. This is important for me to find the best way to modify the database. If it is difficult for you to explain, please send the code for the form. When you post the code all of the code should be between the two code tags like this:

[code]

<%
dim rs1, query
query = "SELECT topOpenFlg FROM table1 WHERE recordID = "
query = query & request.form("r ecordID")
set rs1 = server.createob ject("ADODB.Rec ordset")
rs1.open query, conn, 2,3

rs1("topOpenFlg ") = date()
rs1.update
%>

[/code]

Jared
Nov 7 '07 #8
idsanjeev
241 New Member
hi jhardman
thanks to reply
my deadline of project is very close if i cant submit till tomorw then this project is transferd to other. so please reply soon .
again explained my question what is my target.
i wants to show some records on page from table that can see all and modify any records i wants to modiy then a select list inside all records i.e no,yes,close ,
if i wants to modify any records from display rows then select option from rows inside called apply and click on submit and change only selected rows detail .
but i am in trouble by using this code i able to change all records from table also i am using pagignation to avoide error multiple oledb .
so my question is to help me to modify thats record i wants to modify that is on page so how can modify only thats which i wants.this is my full code plz check my code

Expand|Select|Wrap|Line Numbers
  1.  code is here
  2.  
  3. <%@language=vbscript%>
  4. <%option explicit%>
  5. <%
  6. If Request.Cookies("userid") = "" Then
  7.   Response.Redirect "login.asp"
  8. Else
  9. dim my_conn_stRing, conn,R,R1,R2, sql,Rcount,Rpage,page,i,vopenflg
  10. dim stroutput,reply,repcount,stropt,vtopid
  11. MY_CONN_STRING = "dsn=oracle;uid=starter;pwd=starter;" 
  12. Set Conn = server.createobject("ADODB.Connection")
  13. Conn.open MY_CONN_STRING
  14. set R = Server.CreateObject("ADODB.Recordset")
  15. set R1 = Server.CreateObject("ADODB.Recordset")
  16. set R2 = Server.CreateObject("ADODB.Recordset")
  17. R.open "Select top_id,top_sub,launch_by,launch_dt from topmaster ",conn, adOpenStatic, adLockOptimistic, adCmdText
  18. R.PageSize=1
  19. Repcount=R.RecordCount
  20. Rcount=R.RecordCount 
  21. Rpage=R.PageCount
  22. if Request.QueryString("Reply")="" then
  23. Reply=1 
  24. else
  25.  Reply=cint((Request.QueryString("Reply")))
  26.  end if
  27. if Request.querystring("page")="" then 
  28.   page=1
  29. else
  30.   page=cint((Request.querystring("page")))
  31. end if
  32. %>
  33. <html>
  34. <head><TITLE>Vioce Of Baraunians</TITLE></head>
  35. <body bgcolor="#FFFFFF" background="../SANJEEV/backphoto.gif">
  36. <form name="moderator" action="moderator.asp" method="post">
  37. <!--#include file="front.inc"--><br><br>&nbsp;
  38. <meta http-equiv="Content-Type" content="text/html; charet=iso-8859-1">
  39. <div style="position:absolute; top:100; left:0 ">
  40. <table width="1000" border="0" cellspacing="1" cellpadding="3" bgcolor="#663333" >
  41. <tr bgcolor="#CCCCFF"> 
  42.   <td width="8%" ><b>TOPIC ID</b></td>
  43.   <td bgcolor="#CCCCFF" colspan="100%">&nbsp;&nbsp; <img src="files categories.gif">&nbsp;&nbsp; &nbsp;<b>TOPIC SUBJECT</b></td>
  44.   <td bgcolor="#CCCCFF" width="12%"><img src="group user.gif">&nbsp;&nbsp;<b>POSTED BY</b></td>
  45.   <td bgcolor="#CCCCFF" width="12%"><b>POSTED DATE</b></td>
  46.   <td bgcolor="#CCCCFF"><b>Permission</b></td>
  47.   </tr>
  48.  <%
  49. if not R.eof then
  50. R.Move (page-1)*R.pagesize
  51. end if
  52. if not R.eof then
  53.   for i=1 to R.pagesize
  54.   %> 
  55.   <tr bgcolor="#FFFFFF"> 
  56.     <td bgcolor="#66FF99" width="8%"><%=R("top_id")%></td>
  57.     <td align="left" colspan="100%" bgcolor="#66FF99"><b><font face="arial" size=2><a href=voice.asp?opt=<%=R("top_id")%>><%Response.Write R("top_sub")%></a></font></b></td>
  58.     <td bgcolor="#66FF99" width="12%"><%=R("launch_by")%></td>
  59.     <td bgcolor="#66FF99" width="12%"><%=R("launch_dt")%></td>
  60.          <td width="10%"><font face="arial" size="2"><b>Apply</b></font>
  61.          <select name="vopenflg">
  62.         <%If IsEmpty(vopenflg) or vopenflg = 0 Then%>
  63.           <option value="0" selected>No</option>
  64.           <option value="1">Yes</option>
  65.           <option value="2">clsoe</option>
  66.          <%Elseif vopenflg =1 Then%>
  67.           <option value="0">No</option>
  68.           <option value="1" selected>Yes</option>
  69.           <option value="2">Close</option>
  70.          <%Elseif vopenflg =2 Then%>
  71.           <option value="0">No</option>
  72.           <option value="1">Yes</option>
  73.           <option value="2" selected>Close</option>          
  74.           <%End If%>
  75.       </select>
  76.   </tr>
  77.   <%
  78.   if request.QueryString("opt") then
  79.   stropt=opt
  80.   end if
  81.   if request.QueryString("opt1") then
  82. detail=request.QueryString("opt")
  83. end if
  84.  R.movenext
  85.  If R.EOF Then 
  86.  Exit For 
  87.  end if
  88.  next
  89. end if%> 
  90. </table> 
  91. <table width="1000" border="0" cellspacing="1" cellpadding="3" >
  92. <tr align="right" bgcolor="#99FFFF"> 
  93.   <td><b>Voice of Baraunians views</b></td><td><%Response.write(Application("visitors"))%></td>
  94.   <td> <%If page>1 Then %> <a href="moderator.asp?page=<%=page-1%>">Previous</a> 
  95.     <%end if %> 
  96.     <% If page < rpage Then %> <a href="moderator.asp?page=<%=page+1%>">Next</a> 
  97.     <% end if %> 
  98.     <%if rpage>1 then
  99.           for i=1 to Rpage
  100.               Response.write "<a href=""moderator.asp?page="&i&""">"&i&"</a> "
  101.           next
  102.     end if%> </td>
  103.    </tr>
  104.   </table><br>&nbsp;&nbsp;
  105.  
  106.  <% 
  107.   If Not IsEmpty(Request.Form("submit")) then
  108.    vopenflg = Request.Form("vopenflg")
  109.     vopenflg=trim(vopenflg)
  110.      conn.close
  111.     conn.Mode = adModeReadWrite
  112.    conn.open
  113.   R1.Open "select open_flg from topmaster  ", conn, adOpenStatic, adLockOptimistic, adCmdText
  114.   do while not R1.eof 
  115.   R1("open_flg")=vopenflg
  116.   R1.update
  117.   R1.movenext
  118.   loop
  119.   R1.Close
  120.   conn.close
  121. end if
  122. end if
  123. %>
  124.   <table width=765>
  125.   <tr><td width="60%"></td>
  126.     <td><input type= "submit" name="submit" value="Apply" onclick="update()">
  127.    <input type="button" name="submit" value="Back" onclick="brvoice()">
  128.      <input type ="button" value="EXIT" onClick="window.close()"></td>
  129.   </tr>
  130. </table>
  131. <script language="Javascript">
  132. function brvoice()
  133. {
  134.   window.location = "brvoice.asp"
  135. }
  136.  
  137. function update()
  138. {
  139.   window.location = "moderator.asp"
  140. }
  141.  
  142. </script>
  143. </div>
  144. </form>
  145.  </body>
  146. </html>
  147.  
Nov 7 '07 #9
idsanjeev
241 New Member
hi jhardman
is not clear my question .i wants to show records on page that have one column for select list to modify. i wants select option from list and modify after apply button is pressed but only those row that is selected is possible if not then give me other idea to find records and update after modify so plz understand from both posting and answer to my question.thanks
Nov 7 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

6
9383
by: Fan Ruo Xin | last post by:
I try to copy a table from production system (DB2 UDB EEE V7.2 + fixpak5) to the testing system (DB2 UDB V8.1 + fixpak4a). I moved the data from productions system by using the following steps: On production system: $ db2 "export to xxxxx.del of del select * from xxxxxx" On testing system: I use db2 utility autoload, because I use the autoload cfg script for a long
4
3589
by: MikeY | last post by:
Hi everyone, I have posted earlier this week, but I'm still scratching my head trying to figure out how to change/modify my data back to my db. Using C# Windows forms. I am trying to learn how to modify existing data with in my DB/MSDE. In general, I have textbox's filled with existing data from my "Employee" table. I have amongst other buttons, an "Update" button. Where, when viewing, if I want to change ie the persons name, anyother...
1
2916
by: Henry | last post by:
Hi. I've been trying to modify my dataset and have been unsucessful. Any help would be great. What I have is a dataset in a session variable. Here is what I have done to stored into the dataset via store procedure. Sample Stored Procedure: CREATE PROCEDURE prcGetData AS
1
4023
by: VitorJOL | last post by:
Hello I have a listbox with a datasource.I want to remove a row from listbox but not remove it from the database. How can i do this ? PROBLEM:"Cannot modify the Items collection when the DataSource property is set."
4
6199
by: muttu2244 | last post by:
Hi everybody Am trying to read a csv file "temp.csv", which has the below info, compName macAddr ipAddr opSys
4
2811
by: mimasci | last post by:
Hi, I have tried to write a code that allowed me to modify the value of the cells selected in a table, with excel has been easy. How one approaches selected cells? (To modify the value) How can I translate the code, in MS-Excel, below in a equivalent code in MS-Access ........................................................................................... Sub convSelExtPIDToShortPID()
1
7426
by: sklett | last post by:
I've got a strange situation here. I have a databound DataGridView that also has un-bound columns. When the view loads, I want to update the values of the unbound columns. If I attempt to modify the unbound column's cells in the OnLoad() handler the results are very strange. If I add a button to my view and update the unbound cells in the butt's handler it works fine. Here is an example of the code I'm trying to use (it's test code):...
0
1268
by: Patrick | last post by:
Hello, I want to modify an existing XML-File based on Input in a Form. I used a DataSet to load the XML File with the ReadXml method. I then displayed the relevant entries via the GetChildRows method. I now want to change/add/delete those ChildRows: How can I accomplish this?
22
2031
by: dfm | last post by:
Hi, I cant change the header to display images from a database. It's giving me this error : Warning: Cannot modify header information - headers already sent by (output started at /home/content/d/f/m/dfmcons/html/secwhouse/index.php:18) in /home/content/d/f/m/dfmcons/html/secwhouse/index.php on line 71 Here is the code : <? mysql_connect("$host","$username", "$password"); mysql_select_db("secwhouse"); ?>
0
8356
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8866
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8550
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8639
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7385
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5663
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1772
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.