p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

asp_databases thread: Re: Logic - not able to retrieve records


Message #1 by "jigs gandhi" <newsgroup@h...> on Fri, 1 Dec 2000 09:46:03 +0530
This is a multi-part message in MIME format.



------=_NextPart_000_0331_01C05B7B.84F7A0E0

Content-Type: text/plain;

	charset="iso-8859-1"

Content-Transfer-Encoding: quoted-printable



hi,



the variables are available to page 2 in request collection.

you dont pass it to page 3 so you wont get it on page 3



print the sql statement on page 3



jigs

  ----- Original Message -----

  From: Leo Clayton

  To: ASP Databases

  Sent: Thursday, November 30, 2000 4:46 AM

  Subject: [asp_databases] Logic - not able to retrieve records





  I have a table that I know contains the record I am looking for, but 

for some reason I am unable to access it!  When I check for EOF it 

doesn't find the record and response.writes "There were no records 

found".  Can someone tell me what is going on (what I'm doing wrong)?



  This involves three pages:

  (1) one has a form with a first and last name in it that I submit to 

another ASP page that

  (2) SELECTS a record based upon a first and last name match, if there 

is no match it response writes that message and then "meta=3Drefresh" 

back to the first (original) page.  If there is a match, it goes to 

another page that,

  (3) has a form with two radio buttons, one of which is already 

checked, that determines what table will be updated and then on submit 

goes to another page for further processing.







  Page 2 code:

  <%

      Dim dsn

      dsn=3D"EmployeeMaster"

      Set conn =3D Server.CreateObject("ADODB.Connection")

       conn.Mode=3D3

      conn.open dsn

      Set Session("emp_conn") =3D conn

     

      Set rs =3D Server.CreateObject("ADODB.RecordSet")

     

      sql=3D"SELECT IDNumber FROM EmployeeTable WHERE ((FirstName =3D 

'"&Request.Form("Firstname")&"') AND (LastName =3D '" & 

Request.Form("LastName")&"'))"

      rs.Open sql, conn, 3, 3 

  If rs.EOF Then

          Response.Write ("<STRONG>The was <U>NO MATCHING RECORD</U> FOR 

A PERSON NAME</STRONG> ")

          Response.Write (Request.Form("FirstName"))

          Response.Write " "

          Response.Write (Request.Form("LastName"))

  Else  

          'Response.Write("The Record IDNumber is ")

          'Response.write(rs("IDNumber"))

          Session("IDNumber") =3D rs("IDNumber")

          'Response.Redirect "SelectFileToUpdate3.asp"

  End If



  rs.Close

  Set rs =3D Nothing



  conn.Close

  Set conn =3D Nothing



  Response.Redirect "SelectFileToUpdate2.asp"

  %>



  Page 3 code:

  <%



      Dim dsn

      dsn=3D"EmployeeMaster"

      Set conn =3D Server.CreateObject("ADODB.Connection")

       conn.Mode=3D3

      conn.open dsn

      Set Session("emp_conn") =3D conn

     

      Set rs =3D Server.CreateObject("ADODB.RecordSet")

     

      sql=3D"SELECT IDNumber FROM EmployeeTable WHERE ((FirstName =3D 

'"&Request.Form("Firstname")&"') AND (LastName =3D '" & 

Request.Form("LastName")&"'))"

      rs.Open sql, conn, 3, 3



  If not rs.EOF Then 

          Response.Write("The Record IDNumber is ")

          Response.write(rs("IDNumber"))

          Session("IDNumber") =3D rs("IDNumber")

          Response.write(Session("IDNumber"))

  Else

          Response.Write "There were no records found"

  End If

  %>



  <FORM ACTION=3D"UpdateEmployeeMaster.asp" METHOD=3D"POST" >

  <CENTER>



  <TABLE BORDER=3D0>



  <TR>

  <TD><INPUT TYPE=3D"RADIO" NAME=3D"TableToBeUpdated" VALUE=3D"Employee" 

CHECKED>EMPLOYEE PERSONAL INFO</TD>

  </TR>



  <TR>

  <TD><INPUT TYPE=3D"RADIO" NAME=3D"TableToBeUpdated" 

VALUE=3D"EmployeeSkills" >EMPLOYEE SKILLS INFO</TD>

  </TR>



  <TR>

  <TD></TD>

  <TD ALIGN=3DCENTER COLSPAN=3D2><BR>

  <INPUT TYPE=3D"Submit" VALUE=3D"Select File To Update">  

  <INPUT TYPE=3D"RESET"></TD>

  </TR>

  </TABLE>



  </CENTER>

  </FORM>

  ---

  FREE SOFTWARE DEVELOPMENT CODE, CONTENT, AND

  INSIGHTS IN YOUR INBOX!

  Get the latest and best C++, Visual C++, Java, Visual Basic, and XML 

tips, tools, and

  developments from the experts. Sign up for one or more of EarthWeb?s

  FREE IT newsletters at http://www.earthweb.com today!




$subst('Email.Unsub')









  Return to Index