473,394 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Problems Using UPDATE to modify multiple and non sequential records - a giant conundrum from a total novice....

The records in my database are displayed in a form as follows:
%>
<form action="report-ammend1.42.asp" method="post"name="form">
<table border=1>

<%

x = 1
while RS.EOF=false
%>
<tr><td><input type="hidden" name="SprogNo<%= x %>"
value="<%Response.Write RS.Fields("SprogNo")%>"><% response.write
(RS.Fields("SprogNo"))%></td>
<td><input type="text" name="Report<%= x %>" value="<%Response.Write
RS.Fields("Report")%>"></td>
<td><input type="text" name="rep2<%= x %>" value="<%Response.Write
RS.Fields("rep2")%>"></td></tr>

<%
x = x + 1
RS.movenext
Wend
By specifying integer values for x in the form action file, the
correct data is always udated to the correct record:

Dim DB

Set DB = Server.CreateObject ("ADODB.Connection")
DB.Open ("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA
SOURCE=C:\Inetpub\wwwroot\test\test.mdb")
'Dim rs
Set rs = Server.CreateObject ("ADODB.Recordset")
rs.Open "SELECT * FROM SprogTbl", DB, 2, 2
rs.movefirst
for x = 1 to 3
rs.Fields("SprogNo") = Request.Form("SprogNo" & x)
rs.Fields("Report") = Request.Form("Report" & x)
rs.Fields("rep2") = Request.Form("rep2" & x)
rs.update
RS.movenext
Next
rs.movefirst
However, I need this to work for any (undefined) no. of records and
the records may have been queried to display non-sequential records
for the database.
I can't make any of the three solutions I can think of work:
1. If I could make the field SprogNo (which contains the unique ID
no.) rs.response write into x as an integer, then each record would be
automatically numbered. I would then need some kind of "for each x"
loop before the rs.update statements. Just putting:

Response.Write RS.Fields("SprogNo")=x

in place of x = x+1 doesn't do it........

2. I've also tried tying the update to a WHERE statement. But, the
following will work for a databse of one record only:

Dim strSQL
strSQL = "UPDATE SprogTbl SET Report = '" & Report & _
"', rep2 = '" & rep2 & _
"' WHERE ((SprogTbl.SprogNo)='" & SprogNo & "');"
DB.execute(strSQL)

..... however, I've had no success trying to iterate it's functions
starting with rs.movefirst and then a while rs.EOF=false 'rs.movenext
loop.

3. Finally, I thought it might be worth trying to get the WHERE
statement (above) into the rs.Fields("SprogNo") =
Request.Form("SprogNo" & x) statement. So far all attempts have fallen
foul of syntax errors. e.g. rs.update WHERE ((SprogTbl.SprogNo)='" &
SprogNo & "');
The last two solutions would still require making the update repeat
for each of the fields in some kind of a loop.

Any help gratefully recieved......
Jul 19 '05 #1
0 2382

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Gary | last post by:
I haver a table of students - Say 100 students that I need to be able to update/delete and amend. I know I can do this one student at a time which is simple but lets say I want to see all the...
0
by: Chris Hall | last post by:
The records in my database are displayed in a form as follows: %> <form action="report-ammend1.42.asp" method="post"name="form"> <table border=1> <% x = 1
2
by: mb12036 | last post by:
All- Having a problem installing a DB2 client on a machine running AIX version 5.0. Client appeared to install one time succesfully, then was uninstalled and a reinstall was attempted. For...
8
by: Maxi | last post by:
There is a lotto system which picks 21 numbers every day out of 80 numbers. I have a table (name:Lotto) with 22 fields (name:Date,P1,P2....P21) Here is the structure and sample data: ...
19
by: eric.nave | last post by:
this is a slight change to a fequently asked question around here. I have a table which contains a "sortorder" column where a user can specify some arbitrary order for records to be displayed in. ...
9
by: Kelii | last post by:
I've been trying to get this piece to work for a few hours, but have given up. I hope someone out there can help, I think the issue is relatively straightforward, but being a novice, I'm stumped....
7
by: =?Utf-8?B?V2FubmFiZQ==?= | last post by:
Is there a way to use a gridview in a timecard application, and if so, how? I was looking at using a gridview to display a person's hours worked in a week. To do this, many different data records...
8
by: Michel Esber | last post by:
Hello, Env: DB2 V8 LUW FP16 running Linux create Table X (machine_id varchar(24) not null, ctime timestamp not null); create index iFoo on X (MACHINE_ID, CTIME) allow reverse scans; alter...
4
by: phill86 | last post by:
Hi, i have a form that runs a query in a recordset on the after update method if i copy and paste one record at a time the query picks up the records in the underlying table but if i paste...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...

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.