Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: SV: Re: R: SV: R: Re: FOR....LOOP


Message #1 by =?iso-8859-1?Q?H=E5kan_Frennesson?= <hakan@c...> on Sat, 16 Feb 2002 17:28:59 +0100
Hi!



Maybe these links can get you further:

http://www.4guysfromrolla.com/webtech/121298-1.shtml

http://www.learnasp.com/learn/dbtablepaged.asp

http://www.asp101.com/articles/recordsetpaging/index.asp



Hakan



-----Ursprungligt meddelande-----

Från: Linday Bakharia [mailto:lindsay_bakharia@h...]

Skickat: den 16 februari 2002 16:10

Till: ASP Databases

Ämne: [asp_databases] Re: R: SV: R: Re: FOR....LOOP





Thanks for a quick response.  However, I don't think I state my question

clearly. Here it goes again....



I have already created 2 tables in SQL server (question and answer tables)

question table has 2 fieldnames

id (unique)

question (varchar)



answer table has 4 fieldnames

id (unique)

questionid

description

total



Question table

id   question

1    what language are you using to build your application?

2    How long would it take?



Answer table

id   questionid      description    total

1    1               ASP            0

2    1               CF             0

3    1               PHP            0

4    2               Lotus Notes    0

5    2               Perl           0

6    2               Java           0



*************************

Code sample

*************************

<%

.....

SQL = "SELECT * from question order by id desc"

rs.open sql,conn

do while not rs.eof

	queID = rs("ID")

	sql1 = "select * from answer where questionID="&questionID

	response.write "<b>" & rs("question") & "</b><br>"

	response.write "<input type='hidden' name='questionID'

value="&questionID&">"

	set rs1=conn.execute(sql1)

	do while not rs1.eof

		response.write "<input type=radio name=poll"&questionID

& " value='"&rs1("id")&"'>"&rs1("desccription") & "<br>"

		rs1.movenext

	loop

	rs.movenext

loop

%>



..........



Right now, if I view this page, I would have a long page with a 100

questions on it.

My question is: How should I break it down say like 5 questions on each

page instead of a 100?















> the SQL must insert only 5 fields at a time...

> i design the db in order to let user complete the answers

> or modify them... but your suggestion is good too!

>

>

> -----Messaggio originale-----

> Da: Håkan Frennesson [mailto:hakan@c...]

> Inviato: sabato 16 febbraio 2002 15.31

> A: ASP Databases

> Oggetto: [asp_databases] SV: R: Re: FOR....LOOP

>

>

> Hi!

>

> Just one thought about table design:

> I would to this (for practical reasons)

> tbl_answers only needs a few fields and makes it easier to handle during

> insert:

>

> UserID

> QuestionID

> Answer

>

> That way each page inserts 5 answers=5 records rather than creating one

> record at the beginning and updating for every question page....unless

you

> want to give the user a possibility to change an answer allready given,

then

> I am in deep **** ;-)

>

> Just the thought of making SQL statement with some 100 fields makes me

> tremble :-)

>

> Hakan

>

> -----Ursprungligt meddelande-----

> Från: Giovanni Salucci [mailto:g.salucci@n...]

> Skickat: den 16 februari 2002 15:07

> Till: ASP Databases

> Ämne: [asp_databases] R: Re: FOR....LOOP

>

>

> assuming you are using a database (access or sqlserver) the schema may

be:

>

> THE DATABASE

>

> table questions (you store questions)

> id_question (int)

> question (text or memo)

>

> table user (you store here the registration of users)

> iduser (int autonumber)

> user (text) you store name and surname

>

>

> table answers

> idrecord (int autonumber)

> iduser (int) related with user table

> ans01 (text)

> ans02 (text)

> ....

> ans100 (text)

>

>

>

> ASP files

>

> you need only some files:

> 1) form registration, in which you ask for user data and pass data to

> regisytration.asp

> 2) registration.asp which validate user data and insert them in database,

> then redirect to questionpage

> 3) question form display 5 questions of database. to control which answer

> display you might use a Session variable

> or use querystring. Submitting the form redirect to insert.asp

> 4) insert.asp validate the answers, insert them in table answers, then

> redirect to question.asp for next displaying

> or to final page when all questions are displayed

> 5) final page: you need thanks user to answering lot of pages!!!

>

> remember you need pass from a page to another the iduser to update the

> record...

>

> HTH

>

> Giovanni

>

>

> -----Messaggio originale-----

> Da: Linday Bakharia [mailto:lindsay_bakharia@h...]

> Inviato: sabato 16 febbraio 2002 13.50

> A: ASP Databases

> Oggetto: [asp_databases] Re: FOR....LOOP

>

>

> Sorry my message wasn't clear enough.  My goal is to display 5 questions

> on each page and have a NEXT button at the end of each page to allow the

> user to go to the next page until all the questions are addressed.

>

> > Hi,

> >

> > I am building a data driven Survey application.  It's a long survey

(100

> > questions) and I would like to display 5 questions on each page.  I was

> > sucessfully written a page that could display all the questions and

> values

> > on the web.  I know  a For....Loop would do it but since I am new to

> asp,

> > it's like a pain in neck.

> >

> > I would appreciate if you can give me a line of code or a site where I

> can

> > learn how to do this.

> >

> >

>




> $subst('Email.Unsub').

>

>




> $subst('Email.Unsub').

>

>




> $subst('Email.Unsub').

>






$subst('Email.Unsub').



Message #2 by "voltaire" <voltaire2000@b...> on Sat, 16 Feb 2002 15:08:42 -0300
but, i dont speak English, but i will to try:



Try it





rs.pagesize = 10

rs.cursorlocation=adUseClient

rs.data.open "table", strconn, Adopenfowardonly, adlockreadonly, adcmdtable



for you to move betwen records:



www.yourdomain.com?Page=2

www.yourdomain.com?Page=3

www.yourdomain.com?Page=2



The number of page should be stored in a variable how "intpage", so:



Previous buttom

strquote = "



response.write <a href="& strquote & request.SeverVariables (

"SCRIPT_NAME")"?PAGE= -1" & INTPAGE - 1 &  strquote&  "> Previous page</a>

response.write <a href="& strquote & request.SeverVariables (

"SCRIPT_NAME")"?PAGE= +1" & INTPAGE - 1 &  strquote&  "> nextpage</a>

response.write <a href="& strquote & request.SeverVariables (

"SCRIPT_NAME")"?PAGE= 1 & strquote&  "> first page</a>

response.write <a href="& strquote & request.SeverVariables (

"SCRIPT_NAME")"?PAGE= intpage.pagecount & strquote&  "> last page</a>













----- Original Message -----

From: "Håkan Frennesson" <hakan@c...>

To: "ASP Databases" <asp_databases@p...>

Sent: Saturday, February 16, 2002 1:28 PM

Subject: [asp_databases] SV: Re: R: SV: R: Re: FOR....LOOP





> Quer ter seu próprio endereço na Internet?

> Garanta já o seu e ainda ganhe cinco e-mails personalizados.

> DomíniosBOL - http://dominios.bol.com.br

>

>

>

>

>

> Hi!

>

> Maybe these links can get you further:

> http://www.4guysfromrolla.com/webtech/121298-1.shtml

> http://www.learnasp.com/learn/dbtablepaged.asp

> http://www.asp101.com/articles/recordsetpaging/index.asp

>

> Hakan

>

> -----Ursprungligt meddelande-----

> Från: Linday Bakharia [mailto:lindsay_bakharia@h...]

> Skickat: den 16 februari 2002 16:10

> Till: ASP Databases

> Ämne: [asp_databases] Re: R: SV: R: Re: FOR....LOOP

>

>

> Thanks for a quick response.  However, I don't think I state my question

> clearly. Here it goes again....

>

> I have already created 2 tables in SQL server (question and answer tables)

> question table has 2 fieldnames

> id (unique)

> question (varchar)

>

> answer table has 4 fieldnames

> id (unique)

> questionid

> description

> total

>

> Question table

> id   question

> 1    what language are you using to build your application?

> 2    How long would it take?

>

> Answer table

> id   questionid      description    total

> 1    1               ASP            0

> 2    1               CF             0

> 3    1               PHP            0

> 4    2               Lotus Notes    0

> 5    2               Perl           0

> 6    2               Java           0

>

> *************************

> Code sample

> *************************

> <%

> .....

> SQL = "SELECT * from question order by id desc"

> rs.open sql,conn

> do while not rs.eof

> queID = rs("ID")

> sql1 = "select * from answer where questionID="&questionID

> response.write "<b>" & rs("question") & "</b><br>"

> response.write "<input type='hidden' name='questionID'

> value="&questionID&">"

> set rs1=conn.execute(sql1)

> do while not rs1.eof

> response.write "<input type=radio name=poll"&questionID

> & " value='"&rs1("id")&"'>"&rs1("desccription") & "<br>"

> rs1.movenext

> loop

> rs.movenext

> loop

> %>

>

> ..........

>

> Right now, if I view this page, I would have a long page with a 100

> questions on it.

> My question is: How should I break it down say like 5 questions on each

> page instead of a 100?

>

>

>

>

>

>

>

> > the SQL must insert only 5 fields at a time...

> > i design the db in order to let user complete the answers

> > or modify them... but your suggestion is good too!

> >

> >

> > -----Messaggio originale-----

> > Da: Håkan Frennesson [mailto:hakan@c...]

> > Inviato: sabato 16 febbraio 2002 15.31

> > A: ASP Databases

> > Oggetto: [asp_databases] SV: R: Re: FOR....LOOP

> >

> >

> > Hi!

> >

> > Just one thought about table design:

> > I would to this (for practical reasons)

> > tbl_answers only needs a few fields and makes it easier to handle during

> > insert:

> >

> > UserID

> > QuestionID

> > Answer

> >

> > That way each page inserts 5 answers=5 records rather than creating one

> > record at the beginning and updating for every question page....unless

> you

> > want to give the user a possibility to change an answer allready given,

> then

> > I am in deep **** ;-)

> >

> > Just the thought of making SQL statement with some 100 fields makes me

> > tremble :-)

> >

> > Hakan

> >

> > -----Ursprungligt meddelande-----

> > Från: Giovanni Salucci [mailto:g.salucci@n...]

> > Skickat: den 16 februari 2002 15:07

> > Till: ASP Databases

> > Ämne: [asp_databases] R: Re: FOR....LOOP

> >

> >

> > assuming you are using a database (access or sqlserver) the schema may

> be:

> >

> > THE DATABASE

> >

> > table questions (you store questions)

> > id_question (int)

> > question (text or memo)

> >

> > table user (you store here the registration of users)

> > iduser (int autonumber)

> > user (text) you store name and surname

> >

> >

> > table answers

> > idrecord (int autonumber)

> > iduser (int) related with user table

> > ans01 (text)

> > ans02 (text)

> > ....

> > ans100 (text)

> >

> >

> >

> > ASP files

> >

> > you need only some files:

> > 1) form registration, in which you ask for user data and pass data to

> > regisytration.asp

> > 2) registration.asp which validate user data and insert them in

database,

> > then redirect to questionpage

> > 3) question form display 5 questions of database. to control which

answer

> > display you might use a Session variable

> > or use querystring. Submitting the form redirect to insert.asp

> > 4) insert.asp validate the answers, insert them in table answers, then

> > redirect to question.asp for next displaying

> > or to final page when all questions are displayed

> > 5) final page: you need thanks user to answering lot of pages!!!

> >

> > remember you need pass from a page to another the iduser to update the

> > record...

> >

> > HTH

> >

> > Giovanni

> >

> >

> > -----Messaggio originale-----

> > Da: Linday Bakharia [mailto:lindsay_bakharia@h...]

> > Inviato: sabato 16 febbraio 2002 13.50

> > A: ASP Databases

> > Oggetto: [asp_databases] Re: FOR....LOOP

> >

> >

> > Sorry my message wasn't clear enough.  My goal is to display 5 questions

> > on each page and have a NEXT button at the end of each page to allow the

> > user to go to the next page until all the questions are addressed.

> >

> > > Hi,

> > >

> > > I am building a data driven Survey application.  It's a long survey

> (100

> > > questions) and I would like to display 5 questions on each page.  I

was

> > > sucessfully written a page that could display all the questions and

> > values

> > > on the web.  I know  a For....Loop would do it but since I am new to

> > asp,

> > > it's like a pain in neck.

> > >

> > > I would appreciate if you can give me a line of code or a site where I

> > can

> > > learn how to do this.

> > >

> > >

> >




> > $subst('Email.Unsub').

> >

> >




> > $subst('Email.Unsub').

> >

> >




> > $subst('Email.Unsub').

> >

>




> $subst('Email.Unsub').

>

>




$subst('Email.Unsub').

>





Message #3 by "Linday Bakharia" <lindsay_bakharia@h...> on Sun, 17 Feb 2002 14:01:19
Perfect help, Hakan.  I am working on it.  Thanks.





> Hi!

> 

> Maybe these links can get you further:

> http://www.4guysfromrolla.com/webtech/121298-1.shtml

> http://www.learnasp.com/learn/dbtablepaged.asp

> http://www.asp101.com/articles/recordsetpaging/index.asp

> 

> Hakan

> 

> -----Ursprungligt meddelande-----

> Från: Linday Bakharia [mailto:lindsay_bakharia@h...]

> Skickat: den 16 februari 2002 16:10

> Till: ASP Databases

> Ämne: [asp_databases] Re: R: SV: R: Re: FOR....LOOP

> 

> 

> Thanks for a quick response.  However, I don't think I state my question

> clearly. Here it goes again....

> 

> I have already created 2 tables in SQL server (question and answer 

tables)

> question table has 2 fieldnames

> id (unique)

> question (varchar)

> 

> answer table has 4 fieldnames

> id (unique)

> questionid

> description

> total

> 

> Question table

> id   question

> 1    what language are you using to build your application?

> 2    How long would it take?

> 

> Answer table

> id   questionid      description    total

> 1    1               ASP            0

> 2    1               CF             0

> 3    1               PHP            0

> 4    2               Lotus Notes    0

> 5    2               Perl           0

> 6    2               Java           0

> 

> *************************

> Code sample

> *************************

> <%

> .....

> SQL = "SELECT * from question order by id desc"

> rs.open sql,conn

> do while not rs.eof

> 	queID = rs("ID")

> 	sql1 = "select * from answer where questionID="&questionID

> 	response.write "<b>" & rs("question") & "</b><br>"

> 	response.write "<input type='hidden' name='questionID'

> value="&questionID&">"

> 	set rs1=conn.execute(sql1)

> 	do while not rs1.eof

> 		response.write "<input type=radio name=poll"&questionID

> & " value='"&rs1("id")&"'>"&rs1("desccription") & "<br>"

> 		rs1.movenext

> 	loop

> 	rs.movenext

> loop

> %>

> 

> ..........

> 

> Right now, if I view this page, I would have a long page with a 100

> questions on it.

> My question is: How should I break it down say like 5 questions on each

> page instead of a 100?

> 

> 

> 

> 

> 

> 

> 

> > the SQL must insert only 5 fields at a time...

> > i design the db in order to let user complete the answers

> > or modify them... but your suggestion is good too!

> >

> >

> > -----Messaggio originale-----

> > Da: Håkan Frennesson [mailto:hakan@c...]

> > Inviato: sabato 16 febbraio 2002 15.31

> > A: ASP Databases

> > Oggetto: [asp_databases] SV: R: Re: FOR....LOOP

> >

> >

> > Hi!

> >

> > Just one thought about table design:

> > I would to this (for practical reasons)

> > tbl_answers only needs a few fields and makes it easier to handle 

during

> > insert:

> >

> > UserID

> > QuestionID

> > Answer

> >

> > That way each page inserts 5 answers=5 records rather than creating one

> > record at the beginning and updating for every question page....unless

> you

> > want to give the user a possibility to change an answer allready given,

> then

> > I am in deep **** ;-)

> >

> > Just the thought of making SQL statement with some 100 fields makes me

> > tremble :-)

> >

> > Hakan

> >

> > -----Ursprungligt meddelande-----

> > Från: Giovanni Salucci [mailto:g.salucci@n...]

> > Skickat: den 16 februari 2002 15:07

> > Till: ASP Databases

> > Ämne: [asp_databases] R: Re: FOR....LOOP

> >

> >

> > assuming you are using a database (access or sqlserver) the schema may

> be:

> >

> > THE DATABASE

> >

> > table questions (you store questions)

> > id_question (int)

> > question (text or memo)

> >

> > table user (you store here the registration of users)

> > iduser (int autonumber)

> > user (text) you store name and surname

> >

> >

> > table answers

> > idrecord (int autonumber)

> > iduser (int) related with user table

> > ans01 (text)

> > ans02 (text)

> > ....

> > ans100 (text)

> >

> >

> >

> > ASP files

> >

> > you need only some files:

> > 1) form registration, in which you ask for user data and pass data to

> > regisytration.asp

> > 2) registration.asp which validate user data and insert them in 

database,

> > then redirect to questionpage

> > 3) question form display 5 questions of database. to control which 

answer

> > display you might use a Session variable

> > or use querystring. Submitting the form redirect to insert.asp

> > 4) insert.asp validate the answers, insert them in table answers, then

> > redirect to question.asp for next displaying

> > or to final page when all questions are displayed

> > 5) final page: you need thanks user to answering lot of pages!!!

> >

> > remember you need pass from a page to another the iduser to update the

> > record...

> >

> > HTH

> >

> > Giovanni

> >

> >

> > -----Messaggio originale-----

> > Da: Linday Bakharia [mailto:lindsay_bakharia@h...]

> > Inviato: sabato 16 febbraio 2002 13.50

> > A: ASP Databases

> > Oggetto: [asp_databases] Re: FOR....LOOP

> >

> >

> > Sorry my message wasn't clear enough.  My goal is to display 5 

questions

> > on each page and have a NEXT button at the end of each page to allow 

the

> > user to go to the next page until all the questions are addressed.

> >

> > > Hi,

> > >

> > > I am building a data driven Survey application.  It's a long survey

> (100

> > > questions) and I would like to display 5 questions on each page.  I 

was

> > > sucessfully written a page that could display all the questions and

> > values

> > > on the web.  I know  a For....Loop would do it but since I am new to

> > asp,

> > > it's like a pain in neck.

> > >

> > > I would appreciate if you can give me a line of code or a site where 

I

> > can

> > > learn how to do this.

> > >

> > >

> >




> > $subst('Email.Unsub').

> >

> >




> > $subst('Email.Unsub').

> >

> >




> > $subst('Email.Unsub').

> >

> 




> $subst('Email.Unsub').

> 

Message #4 by "Linday Bakharia" <lindsay_bakharia@h...> on Sun, 17 Feb 2002 15:23:08
> Hi!

> 

> Maybe these links can get you further:

> http://www.4guysfromrolla.com/webtech/121298-1.shtml

> http://www.learnasp.com/learn/dbtablepaged.asp

> http://www.asp101.com/articles/recordsetpaging/index.asp

> 

> Hakan

> 

> -----Ursprungligt meddelande-----

> Från: Linday Bakharia [mailto:lindsay_bakharia@h...]

> Skickat: den 16 februari 2002 16:10

> Till: ASP Databases

> Ämne: [asp_databases] Re: R: SV: R: Re: FOR....LOOP

> 

> 

> Thanks for a quick response.  However, I don't think I state my question

> clearly. Here it goes again....

> 

> I have already created 2 tables in SQL server (question and answer 

tables)

> question table has 2 fieldnames

> id (unique)

> question (varchar)

> 

> answer table has 4 fieldnames

> id (unique)

> questionid

> description

> total

> 

> Question table

> id   question

> 1    what language are you using to build your application?

> 2    How long would it take?

> 

> Answer table

> id   questionid      description    total

> 1    1               ASP            0

> 2    1               CF             0

> 3    1               PHP            0

> 4    2               Lotus Notes    0

> 5    2               Perl           0

> 6    2               Java           0

> 

> *************************

> Code sample

> *************************

> <%

> .....

> SQL = "SELECT * from question order by id desc"

> rs.open sql,conn

> do while not rs.eof

> 	queID = rs("ID")

> 	sql1 = "select * from answer where questionID="&questionID

> 	response.write "<b>" & rs("question") & "</b><br>"

> 	response.write "<input type='hidden' name='questionID'

> value="&questionID&">"

> 	set rs1=conn.execute(sql1)

> 	do while not rs1.eof

> 		response.write "<input type=radio name=poll"&questionID

> & " value='"&rs1("id")&"'>"&rs1("desccription") & "<br>"

> 		rs1.movenext

> 	loop

> 	rs.movenext

> loop

> %>

> 

> ..........

> 

> Right now, if I view this page, I would have a long page with a 100

> questions on it.

> My question is: How should I break it down say like 5 questions on each

> page instead of a 100?

> 

> 

> 

> 

> 

> 

> 

> > the SQL must insert only 5 fields at a time...

> > i design the db in order to let user complete the answers

> > or modify them... but your suggestion is good too!

> >

> >

> > -----Messaggio originale-----

> > Da: Håkan Frennesson [mailto:hakan@c...]

> > Inviato: sabato 16 febbraio 2002 15.31

> > A: ASP Databases

> > Oggetto: [asp_databases] SV: R: Re: FOR....LOOP

> >

> >

> > Hi!

> >

> > Just one thought about table design:

> > I would to this (for practical reasons)

> > tbl_answers only needs a few fields and makes it easier to handle 

during

> > insert:

> >

> > UserID

> > QuestionID

> > Answer

> >

> > That way each page inserts 5 answers=5 records rather than creating one

> > record at the beginning and updating for every question page....unless

> you

> > want to give the user a possibility to change an answer allready given,

> then

> > I am in deep **** ;-)

> >

> > Just the thought of making SQL statement with some 100 fields makes me

> > tremble :-)

> >

> > Hakan

> >

> > -----Ursprungligt meddelande-----

> > Från: Giovanni Salucci [mailto:g.salucci@n...]

> > Skickat: den 16 februari 2002 15:07

> > Till: ASP Databases

> > Ämne: [asp_databases] R: Re: FOR....LOOP

> >

> >

> > assuming you are using a database (access or sqlserver) the schema may

> be:

> >

> > THE DATABASE

> >

> > table questions (you store questions)

> > id_question (int)

> > question (text or memo)

> >

> > table user (you store here the registration of users)

> > iduser (int autonumber)

> > user (text) you store name and surname

> >

> >

> > table answers

> > idrecord (int autonumber)

> > iduser (int) related with user table

> > ans01 (text)

> > ans02 (text)

> > ....

> > ans100 (text)

> >

> >

> >

> > ASP files

> >

> > you need only some files:

> > 1) form registration, in which you ask for user data and pass data to

> > regisytration.asp

> > 2) registration.asp which validate user data and insert them in 

database,

> > then redirect to questionpage

> > 3) question form display 5 questions of database. to control which 

answer

> > display you might use a Session variable

> > or use querystring. Submitting the form redirect to insert.asp

> > 4) insert.asp validate the answers, insert them in table answers, then

> > redirect to question.asp for next displaying

> > or to final page when all questions are displayed

> > 5) final page: you need thanks user to answering lot of pages!!!

> >

> > remember you need pass from a page to another the iduser to update the

> > record...

> >

> > HTH

> >

> > Giovanni

> >

> >

> > -----Messaggio originale-----

> > Da: Linday Bakharia [mailto:lindsay_bakharia@h...]

> > Inviato: sabato 16 febbraio 2002 13.50

> > A: ASP Databases

> > Oggetto: [asp_databases] Re: FOR....LOOP

> >

> >

> > Sorry my message wasn't clear enough.  My goal is to display 5 

questions

> > on each page and have a NEXT button at the end of each page to allow 

the

> > user to go to the next page until all the questions are addressed.

> >

> > > Hi,

> > >

> > > I am building a data driven Survey application.  It's a long survey

> (100

> > > questions) and I would like to display 5 questions on each page.  I 

was

> > > sucessfully written a page that could display all the questions and

> > values

> > > on the web.  I know  a For....Loop would do it but since I am new to

> > asp,

> > > it's like a pain in neck.

> > >

> > > I would appreciate if you can give me a line of code or a site where 

I

> > can

> > > learn how to do this.

> > >

> > >

> >




> > $subst('Email.Unsub').

> >

> >




> > $subst('Email.Unsub').

> >

> >




> > $subst('Email.Unsub').

> >

> 




> $subst('Email.Unsub').

> 





Does anybody know what kind of error it is?????  Thanks.



***************************

ADODB.Recordset error '800a0bb9' 



Arguments are of the wrong type, are out of acceptable range, or are in 

conflict with one another. 



/Best/index.asp, line 41 

**************************



<form action="poll.asp?action=vote" method="post" name="theform">

<%

'Set how many records per page we want

    Const NumPerPage = 2



    'Retrieve what page we're currently on

    Dim CurPage

    If Request.QueryString("CurPage") = "" then

        CurPage = 1 'We're on the first page

    Else

        CurPage = Request.QueryString("CurPage")

    End If



Set Conn = Server.CreateObject("ADODB.Connection")

Set Rs = Server.CreateObject("ADODB.Recordset")



'Set the cursor location property

rs.CursorLocation = adUseClient



'Set the cache size = to the # of records/page

rs.CacheSize = NumPerPage

    

Conn.Open dsn

    

SQL = "SELECT * from que order by id desc"

rs.open sql,conn



rs.MoveFirst

    rs.PageSize = NumPerPage



    'Get the max number of pages

    Dim TotalPages

    TotalPages = rs.PageCount



    'Set the absolute page

    rs.AbsolutePage = CurPage



    'Counting variable for our recordset

    Dim count



'Set Count equal to zero

    Count = 0

    Do While Not rs.EOF And Count < rs.PageSize

        queID = rs("ID")

	sql1 = "select * from ans where queID="&queID

	response.write "<b>" & rs("que") & "</b><br>"

	response.write "<input type='hidden' name='queID' value="&queID&">"

	set rs1=conn.execute(sql1)

	do while not rs1.eof

		response.write "<input type=radio name=poll"&queID & " 

value='"&rs1("id")&"'>"&rs1("ansdesc") & "<br>"

		rs1.movenext

	loop

	

        Count = Count + 1

        rs.MoveNext

    Loop



    'Print out the current page # / total pages

    Response.Write("Page " & CurPage & " of " & TotalPages & "<P>")



    'Display Next / Prev buttons

    if CurPage > 1 then

        'We are not at the beginning, show the prev button

        Response.Write("<INPUT TYPE=BUTTON VALUE=PREV 

ONCLICK=""document.location.href='thisfile.asp?curpage=" & curpage - 1 

& "';"">")

    End If



if CInt(CurPage) <> CInt(TotalPages) then

        'We are not at the end, show a next button

        Response.Write("<INPUT TYPE=BUTTON VALUE=NEXT 

ONCLICK=""document.location.href='thisfile.asp?curpage=" & curpage + 1 

& "';"">")

    End If



%>

********************
Message #5 by "voltaire" <voltaire2000@b...> on Mon, 18 Feb 2002 18:22:06 -0300
    Hi, i am learning asp too. I will to send to you the my code . I take it

of the samples of the book "Active server pages 3.0.

I am reading this book. Is very good.



I will look for this book in my home today. Tomorrow i send to you.



by.

----- Original Message -----

From: "Lindsay Bakharia" <lindsay_bakharia@h...>

To: <voltaire2000@b...>

Sent: Monday, February 18, 2002 12:04 AM

Subject: Re: [asp_databases] Re: SV: Re: R: SV: R: Re: FOR....LOOP





> Quer ter seu próprio endereço na Internet?

> Garanta já o seu e ainda ganhe cinco e-mails personalizados.

> DomíniosBOL - http://dominios.bol.com.br

>

>

>

>

>

> Hi Voltaire,

>

> Your English is great.  In addition, what do you need English for if you

> know how to make a program running, correct????

>

> By the way, thanks for trying to help me out here.  However, since I am

new

> to ASP, I have no clue at your codes.  I do think your codes look great

> though.

>

> Talk to you later....

>

> --Lindsay Bakharia--

>

> >From: "voltaire" <voltaire2000@b...>

> >Reply-To: "ASP Databases" <asp_databases@p...>

> >To: "ASP Databases" <asp_databases@p...>

> >Subject: [asp_databases] Re: SV: Re: R: SV: R: Re: FOR....LOOP

> >Date: Sat, 16 Feb 2002 15:08:42 -0300

> >

> >but, i dont speak English, but i will to try:

> >

> >Try it

> >

> >

> >rs.pagesize = 10

> >rs.cursorlocation=adUseClient

> >rs.data.open "table", strconn, Adopenfowardonly, adlockreadonly,

adcmdtable

> >

> >for you to move betwen records:

> >

> >www.yourdomain.com?Page=2

> >www.yourdomain.com?Page=3

> >www.yourdomain.com?Page=2

> >

> >The number of page should be stored in a variable how "intpage", so:

> >

> >Previous buttom

> >strquote = "

> >

> >response.write <a href="& strquote & request.SeverVariables (

> >"SCRIPT_NAME")"?PAGE= -1" & INTPAGE - 1 &  strquote&  "> Previous

page</a>

> >response.write <a href="& strquote & request.SeverVariables (

> >"SCRIPT_NAME")"?PAGE= +1" & INTPAGE - 1 &  strquote&  "> nextpage</a>

> >response.write <a href="& strquote & request.SeverVariables (

> >"SCRIPT_NAME")"?PAGE= 1 & strquote&  "> first page</a>

> >response.write <a href="& strquote & request.SeverVariables (

> >"SCRIPT_NAME")"?PAGE= intpage.pagecount & strquote&  "> last page</a>

> >

> >

> >

> >

> >

> >

> >----- Original Message -----

> >From: "Håkan Frennesson" <hakan@c...>

> >To: "ASP Databases" <asp_databases@p...>

> >Sent: Saturday, February 16, 2002 1:28 PM

> >Subject: [asp_databases] SV: Re: R: SV: R: Re: FOR....LOOP

> >

> >

> > > Quer ter seu próprio endereço na Internet?

> > > Garanta já o seu e ainda ganhe cinco e-mails personalizados.

> > > DomíniosBOL - http://dominios.bol.com.br

> > >

> > >

> > >

> > >

> > >

> > > Hi!

> > >

> > > Maybe these links can get you further:

> > > http://www.4guysfromrolla.com/webtech/121298-1.shtml

> > > http://www.learnasp.com/learn/dbtablepaged.asp

> > > http://www.asp101.com/articles/recordsetpaging/index.asp

> > >

> > > Hakan

> > >

> > > -----Ursprungligt meddelande-----

> > > Från: Linday Bakharia [mailto:lindsay_bakharia@h...]

> > > Skickat: den 16 februari 2002 16:10

> > > Till: ASP Databases

> > > Ämne: [asp_databases] Re: R: SV: R: Re: FOR....LOOP

> > >

> > >

> > > Thanks for a quick response.  However, I don't think I state my

question

> > > clearly. Here it goes again....

> > >

> > > I have already created 2 tables in SQL server (question and answer

> >tables)

> > > question table has 2 fieldnames

> > > id (unique)

> > > question (varchar)

> > >

> > > answer table has 4 fieldnames

> > > id (unique)

> > > questionid

> > > description

> > > total

> > >

> > > Question table

> > > id   question

> > > 1    what language are you using to build your application?

> > > 2    How long would it take?

> > >

> > > Answer table

> > > id   questionid      description    total

> > > 1    1               ASP            0

> > > 2    1               CF             0

> > > 3    1               PHP            0

> > > 4    2               Lotus Notes    0

> > > 5    2               Perl           0

> > > 6    2               Java           0

> > >

> > > *************************

> > > Code sample

> > > *************************

> > > <%

> > > .....

> > > SQL = "SELECT * from question order by id desc"

> > > rs.open sql,conn

> > > do while not rs.eof

> > > queID = rs("ID")

> > > sql1 = "select * from answer where questionID="&questionID

> > > response.write "<b>" & rs("question") & "</b><br>"

> > > response.write "<input type='hidden' name='questionID'

> > > value="&questionID&">"

> > > set rs1=conn.execute(sql1)

> > > do while not rs1.eof

> > > response.write "<input type=radio name=poll"&questionID

> > > & " value='"&rs1("id")&"'>"&rs1("desccription") & "<br>"

> > > rs1.movenext

> > > loop

> > > rs.movenext

> > > loop

> > > %>

> > >

> > > ..........

> > >

> > > Right now, if I view this page, I would have a long page with a 100

> > > questions on it.

> > > My question is: How should I break it down say like 5 questions on

each

> > > page instead of a 100?

> > >

> > >

> > >

> > >

> > >

> > >

> > >

> > > > the SQL must insert only 5 fields at a time...

> > > > i design the db in order to let user complete the answers

> > > > or modify them... but your suggestion is good too!

> > > >

> > > >

> > > > -----Messaggio originale-----

> > > > Da: Håkan Frennesson [mailto:hakan@c...]

> > > > Inviato: sabato 16 febbraio 2002 15.31

> > > > A: ASP Databases

> > > > Oggetto: [asp_databases] SV: R: Re: FOR....LOOP

> > > >

> > > >

> > > > Hi!

> > > >

> > > > Just one thought about table design:

> > > > I would to this (for practical reasons)

> > > > tbl_answers only needs a few fields and makes it easier to handle

> >during

> > > > insert:

> > > >

> > > > UserID

> > > > QuestionID

> > > > Answer

> > > >

> > > > That way each page inserts 5 answers=5 records rather than creating

> >one

> > > > record at the beginning and updating for every question

page....unless

> > > you

> > > > want to give the user a possibility to change an answer allready

> >given,

> > > then

> > > > I am in deep **** ;-)

> > > >

> > > > Just the thought of making SQL statement with some 100 fields makes

me

> > > > tremble :-)

> > > >

> > > > Hakan

> > > >

> > > > -----Ursprungligt meddelande-----

> > > > Från: Giovanni Salucci [mailto:g.salucci@n...]

> > > > Skickat: den 16 februari 2002 15:07

> > > > Till: ASP Databases

> > > > Ämne: [asp_databases] R: Re: FOR....LOOP

> > > >

> > > >

> > > > assuming you are using a database (access or sqlserver) the schema

may

> > > be:

> > > >

> > > > THE DATABASE

> > > >

> > > > table questions (you store questions)

> > > > id_question (int)

> > > > question (text or memo)

> > > >

> > > > table user (you store here the registration of users)

> > > > iduser (int autonumber)

> > > > user (text) you store name and surname

> > > >

> > > >

> > > > table answers

> > > > idrecord (int autonumber)

> > > > iduser (int) related with user table

> > > > ans01 (text)

> > > > ans02 (text)

> > > > ....

> > > > ans100 (text)

> > > >

> > > >

> > > >

> > > > ASP files

> > > >

> > > > you need only some files:

> > > > 1) form registration, in which you ask for user data and pass data

to

> > > > regisytration.asp

> > > > 2) registration.asp which validate user data and insert them in

> >database,

> > > > then redirect to questionpage

> > > > 3) question form display 5 questions of database. to control which

> >answer

> > > > display you might use a Session variable

> > > > or use querystring. Submitting the form redirect to insert.asp

> > > > 4) insert.asp validate the answers, insert them in table answers,

then

> > > > redirect to question.asp for next displaying

> > > > or to final page when all questions are displayed

> > > > 5) final page: you need thanks user to answering lot of pages!!!

> > > >

> > > > remember you need pass from a page to another the iduser to update

the

> > > > record...

> > > >

> > > > HTH

> > > >

> > > > Giovanni

> > > >

> > > >

> > > > -----Messaggio originale-----

> > > > Da: Linday Bakharia [mailto:lindsay_bakharia@h...]

> > > > Inviato: sabato 16 febbraio 2002 13.50

> > > > A: ASP Databases

> > > > Oggetto: [asp_databases] Re: FOR....LOOP

> > > >

> > > >

> > > > Sorry my message wasn't clear enough.  My goal is to display 5

> >questions

> > > > on each page and have a NEXT button at the end of each page to allow

> >the

> > > > user to go to the next page until all the questions are addressed.

> > > >

> > > > > Hi,

> > > > >

> > > > > I am building a data driven Survey application.  It's a long

survey

> > > (100

> > > > > questions) and I would like to display 5 questions on each page.

I

> >was

> > > > > sucessfully written a page that could display all the questions

and

> > > > values

> > > > > on the web.  I know  a For....Loop would do it but since I am new

to

> > > > asp,

> > > > > it's like a pain in neck.

> > > > >

> > > > > I would appreciate if you can give me a line of code or a site

where

> >I

> > > > can

> > > > > learn how to do this.

> > > > >

> > > > >

> > > >




> > > > $subst('Email.Unsub').

> > > >

> > > >




> > > > $subst('Email.Unsub').

> > > >

> > > >




> > > > $subst('Email.Unsub').

> > > >

> > >




> > > $subst('Email.Unsub').

> > >

> > >




> >$subst('Email.Unsub').

> > >

> >

> >

> >




> >$subst('Email.Unsub').

>

>

>

>

> _________________________________________________________________

> Send and receive Hotmail on your mobile device: http://mobile.msn.com

>

>




  Return to Index