Ver Mensaje Individual
  #1 (permalink)  
Antiguo 10/05/2002, 02:32
danipermuy
 
Fecha de Ingreso: abril-2002
Mensajes: 216
Antigüedad: 23 años
Puntos: 0
SOLO EXPERTOS: Variable boolean

Utilizo una variable boolean para ejecutar una u otra consulta según decida el usuario, el codigo es mas o menos asi
Código:
 <%
defino variables y a algunas les doy valores  
dim comercial As String
dim fechaini As String
dim fechafin As String 
dim bwhere As boolean
comercial= "'" & request.form("comercial") & "'"
fechaini="#"&Cdate(request.form("fechaini"))&"#" 
fechafin="#"&Cdate(request.form("fechafin"))&"#"
aki se conecta a la base de datos  
set conexion = createobject("ADODB.connection")
conexion.open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=C:\inetpub\wwwroot\itresa.mdb"
boolean  
bwhere=false

if comercial<>'*' then
	strcomercial="where dni =" & comercial
	bwhere=true
end if

if fechaini<>"" then
	if bwhere=true then
	strfechaini="and fecha >=" &fechaini
	else
	strfechaini="where fecha >=" & fechaini
	bwhere=true
end if

if fechafin<>"" then
	if bwhere=true then
	strfechafin="and fecha <=" &fechafin
	else
	strfechafin="where fecha <=" &fechafin
end if
ejecuta consulta  
strsql="select * from visitas"&strcomercial &strfechaini &strfechafin
set miconexion = conexion.execute (strsql)
Me da error en la definicion de las variables y tambien me da error en el primer if (if comercial<>'*' then...) si no defino las variables, es muy raro!
HELP!!!
Gracias :)