p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   SQL Language (http://p2p.wrox.com/forumdisplay.php?f=100)
-   -   A simple question about databases (http://p2p.wrox.com/showthread.php?t=21208)

menesesg November 13th, 2004 11:00 PM

A simple question about databases
 
Hello,

I hope anybody can help me!!!

This is my first time in Databases, I am using a simple Access Database with the ODBC connection. All I am doing is to ask the user its number employee and then return the information according to its profile and allow the user to access into a certain URL, everything at this point works fine, my query is ok, and the data displays ok, but when the number employee is not in the database I want to send a message telling the user he is not subscribe, and here is my problem I don´t know how to get the method for returning the message, I mean which code I can use to do my condition if(x== "null") or something then Response.Write("Sorry, you are not subscribe"). I think this must be pretty natural but I can´t find the method to do it

Please Help me !! is all I need to finish my work.

Here is my code:

<%@ LANGUAGE="JAVASCRIPT" %>
<html>
<head>
<title>Información general</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.style2 {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    font-weight: bold;
    color: #CC0000;
}
.style5 {font-family: Arial, Helvetica, sans-serif; font-size: 12px; }
-->
</style>
<script language="JavaScript" type="text/JavaScript">
<!--

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//-->
</script>
</head>
<body>
<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="5">
  <TR>
    <TD BGCOLOR="#000066"><B>RESULTADOS DE LA B&Uacute;SQUEDA</B></TD>
  </TR>
</TABLE>

<%
//se genera la conexión con la base de datos y se llena la lista con los resultados


    var expediente = Request.QueryString("exp1");
    var adoConnection = Server.CreateObject("ADODB.Connection");
    var adoRecordSet;
    var mySQL;
    adoConnection.Open("DSN=PdC");
    var mySQL = "SELECT Usuarios.Expediente, Usuarios.Nombre, Perfiles.DescPerf, Curricula.URL" + " FROM (Curricula INNER JOIN (Usuarios INNER JOIN Inscritos ON Usuarios.Expediente = Inscritos.Expediente) ON Curricula.Clave = Inscritos.[Puesto inscrito]) INNER JOIN Perfiles ON Usuarios.Perfil = Perfiles.Clave_perf" + " WHERE (((Inscritos.Expediente))=" + expediente + ")";
    adoRecordSet = adoConnection.Execute(mySQL);

// hace loop en la base y al terminar, trae los datos a la página WEB

    while( adoRecordSet.Eof == false)
    {
%>
<P ALIGN="LEFT"><B>Nombre: <%=adoRecordSet("Nombre").Value%></B></P>
<P ALIGN="LEFT"><B>Número de expediente: <%=adoRecordSet("Expediente").Value%></B></P>
<P ALIGN="LEFT"><B><%=adoRecordSet("DescPerf").Value% ></B></P>
<img src="media/iniciar1.gif" width="82" height="36" onclick="window.location.replace('<%= adoRecordSet("URL").Value%>')">
<%


    adoRecordSet.MoveNext();

}

// cierra el recordset y la conexión
// y libera la memoria utilizada por la rutina del Recordset y los objetos de Conexión

    adoRecordSet.Close();
    adoRecordSet = null;
    adoConnection.Close();
    adoConnection = null;
%>
</TABLE>
<p>
</p>
</body>
</html>



Thanks in advance.

Liliana

happygv November 15th, 2004 03:06 AM

Code:

    var mySQL = "SELECT Usuarios.Expediente, Usuarios.Nombre, Perfiles.DescPerf, Curricula.URL" + " FROM (Curricula INNER JOIN (Usuarios INNER JOIN Inscritos ON Usuarios.Expediente = Inscritos.Expediente) ON Curricula.Clave = Inscritos.[Puesto inscrito]) INNER JOIN Perfiles ON Usuarios.Perfil = Perfiles.Clave_perf" + " WHERE (((Inscritos.Expediente))=" + expediente + ")";
    adoRecordSet = adoConnection.Execute(mySQL);

'Check that here.

    If adoRecordSet.Eof Then
        Response.write "Sorry you are not subscribed"
    ELSE

// hace loop en la base y al terminar, trae los datos a la página WEB

        while( adoRecordSet.Eof == false)
            ...
            ...
        WEND
    END IF

    Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection


All times are GMT -4. The time now is 04:22 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.