Foros del Web » Programando para Internet » ASP Clásico »

recoger un valor en diferentes variables

Estas en el tema de recoger un valor en diferentes variables en el foro de ASP Clásico en Foros del Web. Tengo este código Código: queIDStr = trim(request.form("id_no")) que me recoge los datos que le he pasado ede un formulario y me los pone de la ...
  #1 (permalink)  
Antiguo 11/09/2002, 05:22
 
Fecha de Ingreso: febrero-2002
Ubicación: Navarra
Mensajes: 701
Antigüedad: 22 años, 4 meses
Puntos: 2
recoger un valor en diferentes variables

Tengo este código
Código:
 queIDStr = trim(request.form("id_no"))
que me recoge los datos que le he pasado ede un formulario y me los pone de la forma 203, 207, 253 La pregunta ¿Como puedo poner esta variable 203, 207, 253 en tres diferentes?
  #2 (permalink)  
Antiguo 11/09/2002, 05:58
 
Fecha de Ingreso: septiembre-2002
Ubicación: Burgos
Mensajes: 66
Antigüedad: 21 años, 9 meses
Puntos: 0
Re: recoger un valor en diferentes variables

Tienes una orden para pasarlo a un array:

eso lo haces con la orden Split

Por ejemplo:

identificadores = Split (IDStr,",")
donde identificadores es el nombre del array resultado
IDStr es la cadena
Y , indica el separador utilizado.

Un saludo

"Tengo tan buena memoria como buen olvido"
  #3 (permalink)  
Antiguo 11/09/2002, 06:28
 
Fecha de Ingreso: febrero-2002
Ubicación: Navarra
Mensajes: 701
Antigüedad: 22 años, 4 meses
Puntos: 2
Re: recoger un valor en diferentes variables

Vale tengo la función que me has comentado
Código:
queIDarr = split(queIDStr,",")
y esto me devuelve los números separados???
y estos números o variables que me devuelve como los pongo en la consulta, asi???
Código:
 strSQL = "SELECT * FROM tblPolls WHERE id_no="&trim(queIDarr)
Un saludo
  #4 (permalink)  
Antiguo 11/09/2002, 10:27
Avatar de AlZuwaga
Colaborador
 
Fecha de Ingreso: febrero-2001
Ubicación: 34.517 S, 58.500 O
Mensajes: 14.550
Antigüedad: 23 años, 3 meses
Puntos: 535
Re: recoger un valor en diferentes variables

Fijate de adaptar esto a tus necesidades:

Código:
<%
queIDStr = "200,201,202"
queIDStr = Split(queIDStr, ",")

strSQL = "SELECT * FROM tblPolls WHERE "

For i = 0 To UBound(queIDStr)
	If i <> UBound(queIDStr) then
	strSQL = strSQL & " id_no = " & queIDStr(i) & " or "
	Else
	strSQL = strSQL & " id_no = " & queIDStr(i)
	End if
Next

Response.Write strSQL
%>

Claro que tendrías que cambiar la línea..
Código:
queIDStr = "200,201,202"
por..
Código:
queIDStr = trim(request.form("id_no"))
Lo hice así para probarlo antes de enviarte el código
  #5 (permalink)  
Antiguo 11/09/2002, 10:29
Avatar de urjose  
Fecha de Ingreso: diciembre-2001
Mensajes: 5.286
Antigüedad: 22 años, 5 meses
Puntos: 1
Re: recoger un valor en diferentes variables

Para eso no necesitas separar los valores, solo necesitas hacer algo así:
strSQL = "SELECT * FROM tblPolls WHERE id_no IN "&trim(queIDarr)

Saludos


<center>
<a href=http://comunidadguru.com><img border=0 src=http://comunidadguru.com/imagenes/logos/logo.gif></a>
</center>
  #6 (permalink)  
Antiguo 11/09/2002, 11:08
Avatar de AlZuwaga
Colaborador
 
Fecha de Ingreso: febrero-2001
Ubicación: 34.517 S, 58.500 O
Mensajes: 14.550
Antigüedad: 23 años, 3 meses
Puntos: 535
Re: recoger un valor en diferentes variables

Maldito 'IN'
Siempre me olvido de su existencia
  #7 (permalink)  
Antiguo 11/09/2002, 11:11
 
Fecha de Ingreso: febrero-2002
Ubicación: Navarra
Mensajes: 701
Antigüedad: 22 años, 4 meses
Puntos: 2
Re: recoger un valor en diferentes variables

Gracias dazuaga ya me estaba volviendo loco buscandole una solución, de ahí que alla duplicado el post, :) , lo siento.
He estado probando tu código y funciona muy bien, solo que si pongo &quot;OR&quot; entonces solo me coge un campo u otro, yo lo que necesito es que me coja todos los datos, si le cambio OR por AND me sale un error del tipo:
&quot;El valor de BOF o EOF es True, o el actual registro se eliminó; la operación solicitada requiere un registro actual.&quot;
¿Como lo puedo hacer?
Gracias a tí también urjose, he probado lo que me decías y no me dice que no se puede mostrar la página.
Un saludo
  #8 (permalink)  
Antiguo 11/09/2002, 11:18
 
Fecha de Ingreso: febrero-2002
Ubicación: Navarra
Mensajes: 701
Antigüedad: 22 años, 4 meses
Puntos: 2
Re: recoger un valor en diferentes variables

Ya no me sale ese error lo pruebo y os comento
  #9 (permalink)  
Antiguo 11/09/2002, 11:34
 
Fecha de Ingreso: febrero-2002
Ubicación: Navarra
Mensajes: 701
Antigüedad: 22 años, 4 meses
Puntos: 2
Re: recoger un valor en diferentes variables

Vale pues no sale, si pongo OR entonces solo me graba en primer Id y si le pongo And entonces me sale un error interno del servidor
Haber voy a poner el código que estoy utilizando, que no es mio, que lo he cogido de un ejemplo, lo que pasa es que yo estoy aumentando los registros. El código es de un ejemplo para hacer encuestas o votaciones, según se mire, el código es de Web Wiz Guide ASP Weekly Poll v3.04.
Este es el código que estoy utilizando:
Código:
&lt;% Option Explicit %&gt;
&lt;% Response.Buffer = True %&gt;
&lt;!--#include file=&quot;common.inc&quot; --&gt;
&lt;%
'Dimension variables
Dim rsWeeklyPoll 		'Database Recordset Variable
Dim strPollVote			'Holds the poll vote choice from the user
Dim strPollQuestion 		'Holds the poll question
Dim intPollIDNum		'Holds the poll ID Number
Dim intToatalPollVotes		'Holds the total number of votes cast
Dim dblPollVotePercentage	'Holds the percentage of the poll votes choice
Dim intSelectionLoopCounter	'Loop counter to display the poll selections
Dim intReadInVotesLoopCounter	'Loop counter to read in the number of votes cast
Dim blnSaveVote			'Boolean to set to false if the user has already voted
Dim Email
Dim NPregunta
Dim textolibre, queIDStr, queIDarr, sd, sd2, ansID, i, x, NumeroID, id_no

'Initialise variables
intPollIDNum = 0
intToatalPollVotes = 0
blnSaveVote = True
queIDStr = trim(request.form(&quot;id_no&quot;))
queIDStr = Split(queIDStr, &quot;,&quot;)

	
'If this is not a previous poll to be displayed then read in the details from the form and save the choice
If Request.QueryString(&quot;PollID&quot;) = &quot;&quot; Then

	'Read in the Poll ID Number
	intPollIDNum = CInt(Request.Form(&quot;id&quot;))
	
	'Read in the Poll Vote user choice
	strPollVote = Request.Form(&quot;PollVote&quot;)
Sigue
  #10 (permalink)  
Antiguo 11/09/2002, 11:36
 
Fecha de Ingreso: febrero-2002
Ubicación: Navarra
Mensajes: 701
Antigüedad: 22 años, 4 meses
Puntos: 2
Re: recoger un valor en diferentes variables

Código:
 
'If a vote has been cast then record the vote
	If NOT strPollVote = &quot;&quot; Then
	
		'Call the Save Poll Votes Function (This must be called before any HTML is written as it sets a Cookie)
		blnSaveVote =  SavePollVotes(strPollVote, intPollIDNum)
	
	End If

'Else this is a previous poll to display so show get the poll id number to display
Else

	'Read in the Poll ID Number of the previous poll to display
	intPollIDNum = CInt(Request.QueryString(&quot;PollID&quot;))

End If
Email = Request (&quot;email&quot;)
%&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-7759-1&quot;&gt;
&lt;title&gt;Encuestas Copysan&lt;/title&gt;
&lt;!--#include file=&quot;style.asp&quot;--&gt;
&lt;%=Email%&gt;

&lt;/head&gt;
&lt;body bgcolor=&quot;#F0F0F0&quot; vlink=&quot;#48576C&quot; link=&quot;#48576C&quot; alink=&quot;#000000&quot;&gt;
&lt;%
      


	'Display the HTML for the weekly poll	
	
	'If the user has already voted once before in this poll vote then display the approriate message
	If blnSaveVote = False Then
		'If the user has already voted then display an appriorate message
		Response.Write vbCrLf &amp; &quot;&lt;div align=&quot;&quot;center&quot;&quot;&gt;&lt;span class=&quot;&quot;text&quot;&quot;&gt;Lamentable, Ud ya ha votado en esta encuesta.&lt;/span&gt;&lt;/div&gt;&lt;br&gt;&quot;
	End If
 %&gt;
	  &lt;%If blnSaveVote = False Then%&gt;
	  &lt;%else%&gt;
&lt;table width=&quot;97%&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; align=&quot;center&quot;&gt;
  &lt;tr&gt; 
    &lt;td align=&quot;center&quot; valign=&quot;bottom&quot; height=&quot;29&quot;&gt;La 
      encuesta ha sido enviada correstamente, &lt;br&gt;
      muchas gracias por su participaci&amp;oacute;n&lt;/td&gt;
  &lt;/tr&gt;
&lt;/table&gt;
&lt;%end if%&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;%

'Sub function to save the users Poll Vote Choice

Private Function SavePollVotes(ByRef strPollVoteChoice, ByRef intPollIDNum)

	'Dimension variables
	Dim rsSavePollVotes 		'Database Recordset Variable
	Dim intVoteChoiceCount		'Holds the number of votes for the choice selected
	Dim intVotedIDNo		'Holds the number of any previous polls the user has voted in
	
	
	'Intialise variables
	SavePollVotes = True
sigue
  #11 (permalink)  
Antiguo 11/09/2002, 11:40
 
Fecha de Ingreso: febrero-2002
Ubicación: Navarra
Mensajes: 701
Antigüedad: 22 años, 4 meses
Puntos: 2
Re: recoger un valor en diferentes variables

Código:
'Check the user has not already voted by reading in a cookie from there system
	'Read in the Poll ID number of the last poll the user has voted in
	intVotedIDNo = CInt(Request.Cookies(&quot;Poll&quot;)(&quot;PollID&quot;))
	
	'Check to see if the user has voted in this poll
	If intVotedIDNo = intPollIDNum Then
	
		'If the user has already voted then return flase
		SavePollVotes = False
	
	'Else if the user has not already voted so increment the vote choice total and set a cookie on the users system
	Else
		
		'Read in the vote choice numbers from the database
		'Create a recordset odject
		Set rsSavePollVotes = Server.CreateObject(&quot;ADODB.Recordset&quot;)		
		
		'First we need to read in the present vote number so we can add 1 to it
		'Initalise the strSQL variable with an SQL statement to query the database

strSQL = &quot;SELECT * FROM tblPolls WHERE &quot;

For i = 0 To UBound(queIDStr)
If i &lt;&gt; UBound(queIDStr) then
strSQL = strSQL &amp; &quot; id_no = &quot; &amp; queIDStr(i) &amp; &quot; and &quot;
Else
strSQL = strSQL &amp; &quot; id_no = &quot; &amp; queIDStr(i)
End if
Next
		
		'Set the cursor type property of the recordset to Dynamic so we can navigate through the record set
		rsSavePollVotes.CursorType = 2
	
		'Set the Lock Type for the records so that the recordset is only locked when it is updated
		rsSavePollVotes.LockType = 3
		
		'Query the database
		rsSavePollVotes.Open strSQL, strCon


'Do While Not rsSavePollVotes.EOF

			textolibre = Request.Form(&quot;textolibre&quot;)	
			rsSavePollVotes(&quot;textolibre&quot;) =  textolibre

		'Read in the value of the vote choice selected form the database	
		intVoteChoiceCount = CInt(rsSavePollVotes(strPollVoteChoice))
		      	
		'Increment the vote choice by 1
		intVoteChoiceCount = intVoteChoiceCount + 1
		 		 
		    
		'Update the database with the new poll results	
		rsSavePollVotes.Fields(strPollVote) = CInt(intVoteChoiceCount)			
		rsSavePollVotes.Update
sigue
  #12 (permalink)  
Antiguo 11/09/2002, 11:44
 
Fecha de Ingreso: febrero-2002
Ubicación: Navarra
Mensajes: 701
Antigüedad: 22 años, 4 meses
Puntos: 2
Re: recoger un valor en diferentes variables

Código:
 'Re-run the query to read in the updated recordset from the database for the poll results
		rsSavePollVotes.Requery
		
					
	 'rsSavePollVotes.MoveNext
	 'Loop
		
	
		'Reset Server Objects 
		Set adoCon = Nothing
		rsSavePollVotes.Close
		Set rsSavePollVotes = Nothing 
	 	
		'If multiple votes for a poll are not allowed then save a cookie on the users system
		If blnMultipleVotes = False Then 
			'Write a cookie with the Poll ID number so the user cannot keep voting on this poll		
			'Write the cookie with the name Poll containing the value PollID
			Response.Cookies(&quot;Poll&quot;)(&quot;PollID&quot;) = intPollIDNum
			
			'Set the expiry date for 1 year
			Response.Cookies(&quot;Poll&quot;).Expires = Now() + 360
		End If

	End If
	
End Function

%&gt;
fin

Y de paso otra pregunta, con esta variable:
Código:
			textolibre = Request.Form(&quot;textolibre&quot;)	
			rsSavePollVotes(&quot;textolibre&quot;) =  textolibre
Lo que hago es recoger lo que se ha escrito en un campo de texto y escribirlo en la base de datos, el problema es que cuando otro usuario escribe otra opinión la anterior opinión se borra y se escribe esta nueva, la pregunta ¿Como puedo mantener todas las opiniones en un mismo campo?
Un saludo
  #13 (permalink)  
Antiguo 11/09/2002, 15:52
 
Fecha de Ingreso: febrero-2002
Ubicación: Navarra
Mensajes: 701
Antigüedad: 22 años, 4 meses
Puntos: 2
Re: recoger un valor en diferentes variables

dazuaga, Urjose, podeis decirme alguna cosa, porque no puedo poner AND en lugar de OR??? Porque solo me escribe los datos en el primer Id?? Bueno eso ya lo se, es por lo del OR.... Podeis ayudarme,
Un saludo
  #14 (permalink)  
Antiguo 11/09/2002, 15:56
 
Fecha de Ingreso: febrero-2002
Ubicación: Navarra
Mensajes: 701
Antigüedad: 22 años, 4 meses
Puntos: 2
Re: recoger un valor en diferentes variables

Se me olvidaba urjose, tu respuesta es correcta, si funciona.
Un saludo
  #15 (permalink)  
Antiguo 11/09/2002, 17:57
Avatar de AlZuwaga
Colaborador
 
Fecha de Ingreso: febrero-2001
Ubicación: 34.517 S, 58.500 O
Mensajes: 14.550
Antigüedad: 23 años, 3 meses
Puntos: 535
Re: recoger un valor en diferentes variables

ummm es que son muchas líneas de código. por qué no nos comentás en que línea exactamente arroja el error?
  #16 (permalink)  
Antiguo 11/09/2002, 22:34
Avatar de urjose  
Fecha de Ingreso: diciembre-2001
Mensajes: 5.286
Antigüedad: 22 años, 5 meses
Puntos: 1
Re: recoger un valor en diferentes variables

Bueno de hecho mi respuesta no fue correcta, lo correcto sería:

strSQL = &quot;SELECT * FROM tblPolls WHERE id_no IN (&quot;&amp;trim(queIDarr) &amp;&quot;)&quot;



<center>
<a href=http://comunidadguru.com><img border=0 src=http://comunidadguru.com/imagenes/logos/logo.gif></a>
</center>
  #17 (permalink)  
Antiguo 12/09/2002, 03:38
 
Fecha de Ingreso: febrero-2002
Ubicación: Navarra
Mensajes: 701
Antigüedad: 22 años, 4 meses
Puntos: 2
Re: recoger un valor en diferentes variables

Tienes razón dazuaga, haber yo creo que el fallo está aquí:
Código:
 		Set rsSavePollVotes = Server.CreateObject(&quot;ADODB.Recordset&quot;)		
		
		'First we need to read in the present vote number so we can add 1 to it
		'Initalise the strSQL variable with an SQL statement to query the database


queIDStr = trim(request.form(&quot;id_no&quot;))
queIDStr = Split(queIDStr, &quot;,&quot;)
'queIDarr = Split(queIDStr, &quot;,&quot;)

strSQL = &quot;SELECT * FROM tblPolls WHERE &quot;

For i = 0 To UBound(queIDStr)
If i &lt;&gt; UBound(queIDStr) then
strSQL = strSQL &amp; &quot; id_no = &quot; &amp; queIDStr(i) &amp; &quot; or &quot;
Else
strSQL = strSQL &amp; &quot; id_no = &quot; &amp; queIDStr(i)
End if
Next

		'strSQL = &quot;SELECT * FROM tblPolls WHERE id_no IN (&quot;&amp;trim(queIDStr)&amp;&quot;)&quot;

response.write strSQL

		'Set the cursor type property of the recordset to Dynamic so we can navigate through the record set
		rsSavePollVotes.CursorType = 2
	
		'Set the Lock Type for the records so that the recordset is only locked when it is updated
		rsSavePollVotes.LockType = 3
		
		'Query the database
		rsSavePollVotes.Open strSQL, strCon


'Do While Not rsSavePollVotes.EOF
'response.write strSQL
			textolibre = Request.Form(&quot;textolibre&quot;)	
			rsSavePollVotes(&quot;textolibre&quot;) =  textolibre

		'Read in the value of the vote choice selected form the database	
		intVoteChoiceCount = CInt(rsSavePollVotes(strPollVoteChoice))
		      	
		'Increment the vote choice by 1
		intVoteChoiceCount = intVoteChoiceCount + 1
		 		 
		    
		'Update the database with the new poll results	
		rsSavePollVotes.Fields(strPollVote) = CInt(intVoteChoiceCount)			
		rsSavePollVotes.Update

		'Re-run the query to read in the updated recordset from the database for the poll results
		rsSavePollVotes.Requery
		
					
	'rsSavePollVotes.MoveNext
	'Loop
Si le pongo el
Código:
'Do While Not rsSavePollVotes.EOF
activo entonces me graba en la BD 4000 votos.
Un saludo
  #18 (permalink)  
Antiguo 12/09/2002, 04:28
 
Fecha de Ingreso: febrero-2002
Ubicación: Navarra
Mensajes: 701
Antigüedad: 22 años, 4 meses
Puntos: 2
Re: recoger un valor en diferentes variables

Haber yo creo que esto debería ser así:
1-Se hace el recorrido por la página.
2-Me lee la consulta a la BD y me determina cuantos Ids tengo, en este caso 3
3-Me hace la consulta por cada Id, empezamos por el 203
4-Lee la zona del update y me guarda los datos en la BD, en el id 203
5-Me vuelve al principio y me hace la consulta al número 207, de aquí pasaríamos otra vez al punto número 4.
Esto creo que es así, pero no logro hacerlo en el código .
Gracias Urjose por la aclaración de los parentesis, ya los había puesto y he comprobado que funciona, no sabía esa propiedad del In, sigo utilizando el código de dazuaga por que lo entiendo mejor ya que es más visual.
Un saludo
  #19 (permalink)  
Antiguo 12/09/2002, 10:14
 
Fecha de Ingreso: febrero-2002
Ubicación: Navarra
Mensajes: 701
Antigüedad: 22 años, 4 meses
Puntos: 2
Re: recoger un valor en diferentes variables

Creo que el error puede estar aquí:
esta página se llama wekly_poll.asp
Código:
rsSavePollVotes.Fields(strPollVote) = CInt(intVoteChoiceCount)
La variable strPollVote corresponde a:
Código:
 strPollVote = Request.Form(&quot;PollVote&quot;)
de donde PollVote viene de la página formulario que se llama encuestaweb.asp y el código de ese campo es:
Código:
 if NPregunta=&quot;1&quot; then
				Response.Write vbCrLf &amp; &quot;	&lt;tr&gt;&lt;td colspan=&quot;&quot;2&quot;&quot;&gt;&lt;span class=&quot;&quot;smPollText&quot;&quot;&gt;&lt;input type=&quot; &amp; result(&quot;campoT&quot;) &amp; &quot; name=&quot;&quot;PollVote&quot;&quot; value=&quot;&quot;Votes_&quot; &amp; intSelectionLoopCounter &amp; &quot;&quot;&quot;&gt;&quot;
				else
				Response.Write vbCrLf &amp; &quot;	&lt;tr&gt;&lt;td colspan=&quot;&quot;2&quot;&quot;&gt;&lt;span class=&quot;&quot;smPollText&quot;&quot;&gt;&lt;input type=&quot; &amp; result(&quot;campoT&quot;) &amp; &quot; name=&quot;&quot;PollVote&quot; &amp; id_no &amp;&quot; value=&quot;&quot;Votes_&quot; &amp; intSelectionLoopCounter &amp; &quot;&quot;&quot;&gt;&quot;
				end if
En donde le digo que se NPregunta es uno, ese campo se llame PollVote y que si es más de 1 se llame
Código:
 name=&quot;&quot;PollVote&quot; &amp; id_no &amp;&quot;
de la cual optenemos PollVote207 y PollVote253.
El problema es que al recuperar la variable solo recuper la que se llama PollVote y no el resto.
Si PollVote lo recupero asi:
Código:
 strPollVote = Request.Form(&quot;PollVote&quot;)
, como recupero los otros y lo más importante como le pongo en la función:
Código:
 rsSavePollVotes.Fields(strPollVote) = CInt(intVoteChoiceCount)
para que me recorrar todos los campos que he optenido, en este caso 203,207,253
Haber si alguien me puede ayudar...
Un saludo
  #20 (permalink)  
Antiguo 12/09/2002, 10:32
 
Fecha de Ingreso: febrero-2002
Ubicación: Navarra
Mensajes: 701
Antigüedad: 22 años, 4 meses
Puntos: 2
Re: recoger un valor en diferentes variables

Aquí os dejo una dirección para que veais la página encuestasweb.asp, si veis el código html veréis que cada botón radio de cada tabla tiene un nombre diferente, en este caso hay tres diferentes PollVotte, PollVotte207, PollVotte253
<a href='ir.asp?http://www.copysan.com/pruebas/encuestas/encuestaweb.asp?Nombre_Encuesta=ver_8' target='_blank'>http://www.copysan.com/pruebas/encuestas...</a>
Un saludo
  #21 (permalink)  
Antiguo 12/09/2002, 12:09
 
Fecha de Ingreso: febrero-2002
Ubicación: Navarra
Mensajes: 701
Antigüedad: 22 años, 4 meses
Puntos: 2
Re: recoger un valor en diferentes variables

Pues no está el fallo ahí, en:
Código:
 rsSavePollVotes.Fields(strPollVote) = CInt(intVoteChoiceCount)
, esto me recoge el valor del formulario, si he votado en la primera casilla de da como resultado de strPollVote = Vote_1 y me guarda ese resultado en la BD.
O puede que si lo esté, estoy perdido no se como continuar....
Un saludo
  #22 (permalink)  
Antiguo 12/09/2002, 16:01
 
Fecha de Ingreso: febrero-2002
Ubicación: Navarra
Mensajes: 701
Antigüedad: 22 años, 4 meses
Puntos: 2
Re: recoger un valor en diferentes variables

De verdad nadie sabe como hacer esto???

El código que me falla es este, la consulta la hace bien, gracias a dazuaga y a urjose, pero solo me guarda los datos en un ID, así que faltaría que los guardase en los tres ID a la vez, tendría que ponerle un bucle para hacer esto???
Código:
Set rsSavePollVotes = Server.CreateObject(&quot;ADODB.Recordset&quot;)		
queIDStr = trim(request.form(&quot;id_no&quot;))
queIDStr = Split(queIDStr, &quot;,&quot;)

strSQL = &quot;SELECT * FROM tblPolls WHERE &quot;

For i = 0 To UBound(queIDStr)
If i &lt;&gt; UBound(queIDStr) then
strSQL = strSQL &amp; &quot; id_no = &quot; &amp; queIDStr(i) &amp; &quot; or &quot;
Else
strSQL = strSQL &amp; &quot; id_no = &quot; &amp; queIDStr(i)
End if
Next

rsSavePollVotes.CursorType = 2
	
rsSavePollVotes.LockType = 3
		
rsSavePollVotes.Open strSQL, strCon

response.write strSQL

'Esto me guarda el valor de un campo de texto en la BD, el problema es que cada vez que le doy a enviar al formulario, me borra el campo anterior y me pone el nuevo, lo que quiero es que se guarden todas las respuestas, separadas por un &quot;-&quot; o lo que sea, sabeis como se hace esto???
textolibre = Request.Form(&quot;textolibre&quot;)	
rsSavePollVotes(&quot;textolibre&quot;) =  textolibre

'Read in the value of the vote choice selected form the database	
intVoteChoiceCount = CInt(rsSavePollVotes(strPollVoteChoice))
		      	
'Increment the vote choice by 1
intVoteChoiceCount = intVoteChoiceCount + 1
		 		 
'Update the database with the new poll results	
'El strPollVote lo recoge de strPollVote = Request.Form(&quot;PollVote&quot;), donde PollVote es el nombre de los botones radio, que se llaman (Vote_1,Votre_2...), en este caso me coge Vote_1 del Id 203, pero y de los demas ID????
rsSavePollVotes.Fields(strPollVote) = CInt(intVoteChoiceCount)			
rsSavePollVotes.Update

'Re-run the query to read in the updated recordset from the database for the poll results
rsSavePollVotes.Requery
De verdad que nadie puede ayudarme en esto, me estoy poniendo malo de ver el mismo código una y otra vez.
Un saludo
  #23 (permalink)  
Antiguo 12/09/2002, 16:55
 
Fecha de Ingreso: febrero-2002
Ubicación: Navarra
Mensajes: 701
Antigüedad: 22 años, 4 meses
Puntos: 2
Re: recoger un valor en diferentes variables

Ahora en el código me hace la selección toda a la vez
Código:
 SELECT * FROM tblPolls WHERE id_no = 203 or id_no = 207 or id_no = 253
, como podría hacerlo para que me cogiera un dato diferente cada vez que pasa por ese bucle, es decir, cogería primero este id
Código:
 SELECT * FROM tblPolls WHERE id_no = 203
, despues el otro
Código:
 SELECT * FROM tblPolls WHERE id_no = 207
,y por último
Código:
 SELECT * FROM tblPolls WHERE id_no = 253
. Es para que cada vez que me lea un id, me guarde los datos en la BD, y cuando haya grabado uno, haga el mismo recorrido me seleccione el otro id y me guarde esos dato. , no lo se....
Un saludo
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 18:02.