Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: Inserting after checking its criteria from other table


Message #1 by "bindiya" <bindiya@d...> on Tue, 11 Dec 2001 15:22:18 +0530

This is a multi-part message in MIME format.



------=_NextPart_000_000E_01C18257.9EFC8740

Content-Type: text/plain;

	charset="iso-8859-1"

Content-Transfer-Encoding: quoted-printable



Respected Sir

please help

I have a small Problem this code which is attached to it is  using one

database and 2 different tables from same database .It checks  whether

the entered data from the html page is present in book table and then if

present it should inform if he is already a member or insert the record  



,but every time even after being member it inserts record(means  it

never goes to the else statement ,nor does it gives any error .it just

goes to the  if and inserts data inputted by the user  .

Code   for ASP as follow





<%@ language=3D"VBScript"%>

<%Option Explicit%>

<%

Dim objRS

Dim objConn

dim objps

on error resume next

set objConn =3DServer.CreateObject("ADODB.Connection")

objConn.Open "DRIVER=3D{Microsoft Access Driver (*.mdb)};" & _

    "DBQ=3D" & Server.MapPath("db1.mdb") & ";"

   

objConn.open

set objRS =3DServer.CreateObject("ADODB.Recordset")

set Getemp=3DobjConn.Execute("SELECT * from  book where 

EmpNo=3D"&Request.Form("EmpID"))

if Getemp.EOF then

objConn.Execute "INSERT into Land values('" & Request.Form("EmpId") & 

"','" & Request.Form("EmpName") & "','" & Request.Form("BookName") & 

"')"

else

Response.Write"<p>already registered."

End if



objRS.Close



objConn.Close

%>

<HTML>

<HEAD>

</HEAD>

<BODY bgcolor=3D"#ddddff">

<div align=3D"center">

  <p><font size=3D"4"><i><b><font color=3D"#0000FF">Thank you for 

registration. </font></b></i></font></p>

  <p><b><i><font size=3D"4" color=3D"#FF0000">We will get Back to you 

soon</font></i></b></p>

</div>

</BODY>

</HTML>





code for html

<HTML>

<HEAD>

<META NAME=3D"GENERATOR" Content=3D"Microsoft Visual Studio 6.0">

<TITLE></TITLE>

</HEAD>

<BODY bgcolor=3D"ddddff">

<table width=3D"93%" border=3D"0" align=3D"center">

  <tr>

    <td height=3D"86">

      <div align=3D"center">

        <img src=3D"niostaffclub.png" width=3D"350" height=3D"50"><br>

        <img src=3D"membershipform.png" width=3D"200" height=3D"40"> 

</div>

    </td>

  </tr>

<tr>

    <td height=3D"99">

      <p><b><i>To,<br>

        The General Secretary,<br>

        NIO STAFF CLUB</i></b><br>

      </p>

      <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b><i>&nbsp; &nbsp;&nbsp;Please 

enroll

        me as a member of the NIO Staff Club .</i></b>

    </td>

  </tr>

  <tr>

    <td><form Method =3Dpost action=3D"

lib2.asp"><p></P>

<P>

        <table>

          <P></P>

          <P> <TBODY>

          <tr>

            <P></P>

            <P>

            <td align =3Dmiddle width=3D"117"><i><b>EmpId :</b></i></td>

            <p></P>

            <P>

            <td align=3Dleft width=3D"108">

              <INPUT TYPE=3DText&nbsp; Name=3D"EmpId">

            </td>

            <p></P>

            <P></P>

          </tr>

          <P></P>

          <P>

          <tr>

            <P>

            <td align =3Dmiddle 

width=3D"117"><i><b>EmpName:</b></i></td>

            <p></P>

            <P>

            <td align=3Dleft width=3D"108">

              <INPUT TYPE=3DText&nbsp; Name=3D"EmpName">

            </td>

            <p></P>

            <P></P>

          </tr>

          <P></P>

          <P>

            <td align =3Dmiddle width=3D"117"><i><b>Email 

ID:</b></i></td>

          <p></P>

          <P>

          <td align=3Dleft width=3D"108">

            <INPUT TYPE=3DText&nbsp; Name=3D"BookName">

          </td>

          </tr>

          <tr>

            <td align =3Dmiddle width=3D"117">&nbsp;</td>

            <td align=3Dleft width=3D"108"> 

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

              <input type=3Dsubmit value=3D"Submit" name=3D"submit" >

            </td>

          </tr>

          <tr>

            <P>

          <tr>

        </table>

 

        <P>&nbsp; </P>

       

</FORM>

</td>

  </tr>

  <tr>

    <td>&nbsp;</td>

  </tr>

</table>

<P>

</BODY>

</HTML>









  Return to Index