Ver Mensaje Individual
  #4 (permalink)  
Antiguo 30/04/2008, 04:01
mariuk
 
Fecha de Ingreso: abril-2008
Mensajes: 3
Antigüedad: 16 años
Puntos: 0
Re: Como consultar a la base de datos a partir de los inputs que rellenes

Hola otra vez, muchas gracias por contestar rapidamente.

ericaadbr, gracias por tu mensaje xo no lo he entendido, quizas porque no soy muy experta en sql.

rdm, hize lo que me dijistes xo no entiendo cuando comentastes:
"Por último, envias este código al motor de base de datos y lo capturas con un recordset, dataset, etc, etc, lo que estés usando para acumular los datos que devuelve el motor."

El problema esta en que no me hace ninguna consulta. Y mi codigo creo q esta bien xo le faltara algo y no se lo q es. Os mando un trozo de mi codigo a ver si me podeis ayudar.

try
{
sConsultaOracle = "select cif, company_name, city, province, zip_code from irm_installers where";

if(sCif!=null && !sCif.equals(""))
{
cadWhere = cadWhere + " cif = '" + sCif + "'";
}
if(sName!=null && !sName.equals(""))
{
if(cadWhere=="")cadWhere = cadWhere + " company_name = '" + sName + "'";
else cadWhere = cadWhere + " and company_name = '" + sName + "'";
}
if(sProvince!=null && !sProvince.equals(""))
{
if(cadWhere=="")cadWhere = cadWhere + " province = '" + sProvince + "'";
else cadWhere = cadWhere + " and province = '" + sProvince + "'";
}
if(sCity!=null && !sCity.equals(""))
{
if(cadWhere=="")cadWhere = cadWhere + " city = '" + sCity + "'";
else cadWhere = cadWhere + " and city = '" + sCity + "'";
}
sConsultaOracle = sConsultaOracle + cadWhere + " order by cif, company_name, province, city";
//creamos el Statement
stmtOracle=connOracle.createStatement();
//ejecutamos la consulta
resOracle=stmtOracle.executeQuery(sConsultaOracle) ;

}
catch( SQLException sqlE )
{
out.println(" Error executing ....... " + sqlE.toString());
bContinue = false;
}
catch( Exception eE )
{
out.println("Unknown exception executing ........<br>" + eE.toString());
bContinue = false;
}
//si todo ha ido bien, seguimos
if(bContinue)
{
//si ha devuelto algun resultado
if(resOracle.next())
{
%>
<table border="0" cellpadding="0" cellspacing="0">
<thead class="fixedHeader">
<tr>
<th width="50">Select</th>
<th width="50">CIF</th>
<th width="75">NAME</th>
<th width="75">CITY</th>
<th width="75">PROVINCE</th>
<th width="75">ZIP CODE</th>
</tr>
</thead>
<tbody class="scrollContent">
<tr>
<td><input name="selectCif" type="radio" value="<%= resOracle.getString("cif")%>"/></td>
<td><%=resOracle.getString("cif")%></td>
<td><%=resOracle.getString("company_name")%></td>
<td><%=resOracle.getString("city")%></td>
<td><%=resOracle.getString("province")%></td>
<td><%=resOracle.getString("zip_code")%></td>
</tr>
<%
}
else //no encontrado NAME comapny con CIF ?
{
out.println("No se ha encontrado instalador con: " + sCif + sName + sProvince + sCity);
bContinue=false;
}

//si existen mas resultados
if(bContinue)
{
.................................................. ..........


Siempre q lo ejecuto me sale: "No se ha encontrado instalador con:......"

Por favor, si podeis ayudarmeeee....muchas gracias de antemano.