Google Answers Logo
View Question
 
Q: Undating several records on one page ( No Answer,   2 Comments )
Question  
Subject: Undating several records on one page
Category: Computers > Programming
Asked by: wellsuited-ga
List Price: $20.00
Posted: 06 Nov 2002 13:17 PST
Expires: 06 Dec 2002 13:17 PST
Question ID: 100620
I have a page on my website where I need to be able to update all
records in the table at the same time. I need the code for the
processing page to do this, and form page if any.

Table name: adminusers
Field names:  ID
              username
              password



Here is the form page.

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/Invoiveppab.asp" -->
<%
Dim Recordset1
Dim Recordset1_numRows

Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_Invoiveppab_STRING
Recordset1.Source = "SELECT * FROM adminusers"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()

Recordset1_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = 10
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%>

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head>

<body>
<form name="form1" method="post" action="">
  <% 
While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF)) 
%>
  <table width="100%" border="0">
    <tr> 
      <td width="11%">Username:</td>
      <td width="89%"> <input name="textfield" type="text"
value="<%=(Recordset1.Fields.Item("username").Value)%>">
        <input name="ID" type="hidden" id="ID"
value="<%=(Recordset1.Fields.Item("ID").Value)%>"></td>
    </tr>
    <tr> 
      <td>Password:</td>
      <td> <input name="textfield2" type="text"
value="<%=(Recordset1.Fields.Item("password").Value)%>"></td>
    </tr>
    <tr> 
      <td>&nbsp;</td>
      <td> <input type="submit" name="Submit" value="Submit"></td>
    </tr>
  </table>
  <% 
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  Recordset1.MoveNext()
Wend
%>
</form>
<p>&nbsp;</p>
</body>
</html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>

Request for Question Clarification by hammer-ga on 06 Nov 2002 13:24 PST
Wellsuited,

I can't tell from your question what fields in your table need to be
updated with what values and when. Could you please be more specific
regarding what you want to happen?

Clarification of Question by wellsuited-ga on 06 Nov 2002 14:05 PST
There are three fields in the table. The ID field is the primary key
which cannot be updated. I want to be able to update the username and
the password field with one form. From my understanding, the form will
post to a process page, and that page will do the updating to the
database.

The initial value of the form will pull from what is already in the
database. Upon submitting the new values will be updated to the
database.

Request for Question Clarification by hammer-ga on 06 Nov 2002 14:27 PST
So, you build a web page with the current values in the database. User
changes some user names and/or passwords by typing over the current
values in the form fields. User clicks Submit. The values they types
are written back to the database.

Is this correct?

Clarification of Question by wellsuited-ga on 06 Nov 2002 15:21 PST
yes, but all the records need to be on one page. Here is what the page
would look like

http://66.56.196.115/update.asp
Answer  
There is no answer at this time.

Comments  
Subject: Re: Undating several records on one page
From: bardentech-ga on 06 Nov 2002 19:51 PST
 
Easiest way to do it is like this:

Build your display page with a loop:

<% For i = 0 to rs.fields.count -1 %>
  ...<TR><TD>...</TD></TR>
<% next %>

When you build the table, name each textbox the name of the field in
the database: <%=rs.fields(i).name%>

Put the value from your recordset in the box: <%=rs.fields(i).value%>

Now pass the form to the processing page and open the recordset for
editing by the unique key you have setup.   Run through a loop and get
all the values from the form using the for each method:
Dim item
for each item in request.form 
rs.fields(item.name) = item.value  <--- not 100% sure of the syntax
here but you get the point

do you get what I'm saying here?  I can pull some code for you in you
need it.  I did this a couple months ago for online property value
website.  We pulled all the values for a property and a person would
update square footage or whatever and we would put that new
information in the database.

John
Subject: Re: Undating several records on one page
From: mathtalk-ga on 08 Nov 2002 08:48 PST
 
Hi, wellsuited-ga:

I'm not sure what you are using on your Web server, but a general (MS)
topic that pertains to this is "disconnected recordsets" in ADO,
although these originated I believe with desktop apps and need a bit
of support on the Web server (IIS) to work in a browser.  Disconnected
recordsets allow for selective updating of just those records which
have been changed by the client without requiring extensive custom
case logic.

Here's a Microsoft article on doing it:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnacc2k2/html/ODC_DisRecordset.asp

but given its generally poor rating by readers (1.4 out of 5), you
will probably want to look at some of the other 400+ sites returned by
my search:

Keywords: "disconnected recordset" ADO Vbscript

://www.google.com/search?hl=en&lr=&ie=UTF-8&oe=UTF-8&q=%22disconnected+recordset%22+ADO+Vbscript&btnG=Google+Search

I especially like the explanatory tone of this one:

http://www.asp-help.com/database/db_ado_rs.asp

regards, mathtalk-ga

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy