Adding Records

J

Jamie Fryatt

Hi everyone, here's what id like to do.

I have a table with 2 fields, name and value

I need to be able to add multiple records quickly, for example I need to add

name value
abc 1
abc 2
abc 3
abc 4
abc 5
abc 6

etc etc, does each record have to be added separately, or is there a way I
can add a chosen number of records, lets say 10, and have the value field
increase by one each time?

sometimes I might have 30+ simple records that need adding quickly, and each
time the first records value will be one, and each record after will
increase by one, is there a way to solve this problem or does each record
have to be added separately?

Thanks

Jamie
 
E

Evertjan.

Jamie Fryatt wrote on 06 feb 2004 in
microsoft.public.inetserver.asp.general:
Hi everyone, here's what id like to do.

I have a table with 2 fields, name and value

I need to be able to add multiple records quickly, for example I need
to add

name value
abc 1
abc 2
abc 3
abc 4
abc 5
abc 6

etc etc, does each record have to be added separately, or is there a
way I can add a chosen number of records, lets say 10, and have the
value field increase by one each time?

sometimes I might have 30+ simple records that need adding quickly,
and each time the first records value will be one, and each record
after will increase by one, is there a way to solve this problem or
does each record have to be added separately?

Are you talking databases, or html tables, or ASP arrays?

Is "adding" adding new records, or adding values of fields?

If I surmize correctly, ASP + HTML table + new records adding:

<table>
<%
for n=1 to 100
t = "<tr><td>abc</td><td>" & n & "</td></tr>"
document.write t
next
%>
</table>

not tested
 
E

Evertjan.

Evertjan. wrote on 06 feb 2004 in microsoft.public.inetserver.asp.general:
<table>
<%
for n=1 to 100
t = "<tr><td>abc</td><td>" & n & "</td></tr>"
document.write t
next
%>
</table>

not tested

response.write

so much for not testing ;-{
 
J

Jamie Fryatt

i am talking about adding records to an access db, using asp.

i need a user to be able to select a number of records to add , ie 20 click
go and a script somehow adds 20 records to the access db, but the value
field must increase by one each time one of the 20 records is added.

hope that makes snese
 
E

Evertjan.

Jamie Fryatt wrote on 06 feb 2004 in
microsoft.public.inetserver.asp.general:
i am talking about adding records to an access db, using asp.

i need a user to be able to select a number of records to add , ie 20
click go and a script somehow adds 20 records to the access db, but
the value field must increase by one each time one of the 20 records
is added.

hope that makes snese

Oh yes it does, [though we are out of snese over here at present]

<%
'' open the database

a = 123

for n=a ot a+19
sql="INSERT INTO MyTable VALUES ('abc', " & n & ")"
CONNECTION.Execute(SQL)
next
%>

It would be better to use an autoincrement field
 
B

Bob Barrows

Jamie said:
i am talking about adding records to an access db, using asp.

i need a user to be able to select a number of records to add , ie 20
click go and a script somehow adds 20 records to the access db, but
the value field must increase by one each time one of the 20 records
is added.
For real efficiency, make the [value] field an autonumber field (per
Evertjan's suggestion), and then create a table called Numbers containing a
single field called Limit in your database and add 20 (or however many
records you intend the user to be able to add at a single shot) records to
the table, like this:

1
2
3
4
5
6
....
20

Then create a saved parameter query in Access called qAddXrecords, with the
following SQL :

Insert Into tblName (name)
Select [pName] FROM Numbers
WHERE [limit] <= [pLimit]

Test the query by running it. Access will prompt you for the values for the
parameters. Once you have verified that it works, save the query, then, in
ASP, do this:

'open a connection, using a variable called "cn", then:
cn.qAddXrecords "abc",20

HTH,
Bob Barrows

PS. "name" and "value" are reserved keywords and should not be used for
object names in your database. See here for the list of words to avoid:
http://www.aspfaq.com/show.asp?id=2080
 
E

Evertjan.

Bob Barrows wrote on 06 feb 2004 in
microsoft.public.inetserver.asp.general:
PS. "name" and "value" are reserved keywords and should not be used for
object names in your database. See here for the list of words to avoid:

The good thing about programming in another language than English is that
we nearly never encounter such mistakes.

We, overhere, would call the fields "naam and "waarde".

;-}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,145
Messages
2,570,825
Members
47,371
Latest member
Brkaa

Latest Threads

Top