p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

asp_databases thread: Deleting Records


Message #1 by Leo Clayton <claytonl@z...> on Wed, 13 Dec 2000 15:35:03 -0500
--=====================_133531397==_.ALT

Content-Type: text/plain; charset="us-ascii"; format=flowed



Can someone tell me why my attempt to DELETE some records from a TABLE is 

not successfully?



I SELECT a person from a table based upon a name passed from a FORM.  Then 

I save the IDNumber in a Session variable, Delete the persons record from 

this TABLE (successfully) and go to another page that is supposed to DELETE 

all of the records that have an IDNumber =  Session("IDNumber").



Here is my code for the page that is successful (DeleteFromEmployeeTable2):

<%

Option Explicit

Dim strConnect

%>



<% Response.Buffer = True %>



<!--#include file="adovbs.inc"-->

<!--#include file="DataStore.inc"-->



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">



<HTML>

<HEAD>

<TITLE>EMPLOYEE MASTER DATABASE - DELETION</TITLE>

</HEAD>



<BODY BGCOLOR="FFFF80">

<CENTER>

<H1>DELETE EMPLOYEE <BR>FROM MASTER DATABASE</H1>

</CENTER>





<%

     Dim dsn, conn, rs, sql

     dsn="EmployeeMaster"

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

      conn.Mode=3

     conn.open dsn

     'Set Session("emp_conn") = conn



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



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

'"&Session("Firstname")&"') AND (LastName = '" & Session("LastName")&"'))"

     Response.Write(sql)

     rs.Open sql, conn, 3, 3

         Session("IDNumber") = rs("IDNumber")

         Response.Write(Session("IDNumber"))



rs.Close

Set rs = Nothing



conn.Close

Set conn = Nothing

%>



<%

Dim objRS, objComm, intNoOfRecords



If Request.Form("DeleteStatus") = "YES" Then



         Set objComm = Server.CreateObject("ADODB.Command")



         objComm.ActiveConnection = strConnect

         objComm.CommandText = "DELETE FROM EmployeeTable WHERE ((FirstName 

= '"&Session("Firstname")&"') AND (LastName = '" & Session("LastName")&"'))"

         objComm.CommandType = adCmdText

         objComm.Execute intNoOfRecords

         Response.Write "<HR><BR>The DELETE command has been executed, "

         Response.Write "Number of records deleted = " & intNoOfRecords & 

"<BR>"

         Response.Write "<B><U>YOU HAVE JUST DELETED</U> "

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

         Response.Write " "

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

         Response.Write "<U>FROM THE EMPLOYEE DATABASE.</U></B> "



         Set objComm = Nothing

         Response.Redirect "DeleteEmployeeSkillRecords.asp"

Else

         Response.Redirect "EmployeeMasterMainMenu.asp"

End If

%>



</BODY>

</HTML>



Here is my code for the page that is unsuccessful 

(DeleteEmployeeSkillRecords.asp):

<%

Option Explicit

Dim strConnect

%>



<!--#include file="adovbs.inc"-->

<!--#include file="DataStore.inc"-->



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">



<HTML>

<HEAD>

<TITLE>EMPLOYEE MASTER DATABASE - DELETION</TITLE>

</HEAD>



<BODY BGCOLOR="FFFF80">

<CENTER>

<H1>DELETING EMPLOYEE SKILL RECORDS<BR>FROM MASTER DATABASE</H1>

</CENTER>



<CENTER>

<%

Response.Write "<B><H3><EM><U>ATTENTION:</U></EM></H3>"

Response.Write "<H4>AFTER YOU HAVE <U>DELETED THIS EMPLOYEE'S</U> <BR>"

Response.Write "INDIVIDUAL SKILL RECORDS FROM THE EMPLOYEE'S SKILLS TABLE 

<BR>"

Response.Write "<U>THERE WILL BE NO REFERENCE'S OF THIS EMPLOYEE ANYWHERE 

IN THIS DATABASE.</U></H4><BR> "

%>

</CENTER>



<%



'Dim objRS, intNoOfRecords, IDNumber

'Set objRs = Server.CreateObject("ADODB.Recordset")



'objRS.Open "EmployeeSkillsTable", strConnect, adOpenStatic, 

adLockOptimistic,adCmdTable



'objRS.Filter = "IDNumber = '"&(Session("IDNumber")&"')"

'Response.Write "We are DELETING ALL of the following records:<BR>"

'While Not objRS.EOF

         'If objRs("IDNumber") = Session("IDNumber") Then

                 'Response.Write (objRs("SkillID"))

                 'Response.Write "<BR>"

                 'objRS.Delete

                 'objRS.MoveNext

         'End If

'Wend



'objRS.Close

Dim objComm, intNoOfRecords



Set objComm = Server.CreateObject("ADODB.Command")



objComm.ActiveConnection = strConnect

objComm.CommandText = "DELETE FROM EmployeeTable WHERE (IDNumber = 

'"&Session("IDNumber")&"')"

objComm.CommandType = adCmdText

objComm.Execute intNoOfRecords

Response.Write "<HR><BR>The DELETE command has been executed,<BR> "

Response.Write "The IDNumber you just tried to DELETE was "

Response.Write(Session("IDNumber")

Response.Write "Number of records deleted = " & intNoOfRecords & "<BR>"

Response.Write "<B><U>YOU HAVE JUST DELETED</U> "

Response.Write (Session("Firstname"))

Response.Write " "

Response.Write (Session("Lastname"))

Response.Write "<U>FROM THE EMPLOYEE DATABASE.</U></B> "



Set objComm = Nothing



Response.Write "We have DELETED ALL REFERENCES TO "

Response.Write (Session("FirstName"))

Response.Write " "

Response.Write (Session("LastName"))

Response.Write " "

Response.Write "from the <STRONG>EMPLOYEE MASTER DATABASE.</STRONG>"





Set objComm = Nothing

%>



</BODY>

</HTML>







--- 

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!  

---

You are currently subscribed to asp_databases as: $subst('Recip.EmailAddr')

To unsubscribe send a blank email to leave-asp_databases-$subst('Recip.MemberIDChar')@p2p.wrox.com








Message #2 by "Dallas Martin" <dmartin@z...> on Wed, 13 Dec 2000 20:00:31 -0500
This is a multi-part message in MIME format.



------=_NextPart_000_0013_01C0653F.5906D960

Content-Type: text/plain;

	charset="iso-8859-1"

Content-Transfer-Encoding: quoted-printable



Sure, sometimes the session variable gets trashed.

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

  From: Leo Clayton

  To: ASP Databases

  Sent: Wednesday, December 13, 2000 3:35 PM

  Subject: [asp_databases] Deleting Records





  Can someone tell me why my attempt to DELETE some records from a TABLE 

is not successfully?



  I SELECT a person from a table based upon a name passed from a FORM.  

Then I save the IDNumber in a Session variable, Delete the persons 

record from this TABLE (successfully) and go to another page that is 

supposed to DELETE all of the records that have an IDNumber =3D  

Session("IDNumber").



  Here is my code for the page that is successful 

(DeleteFromEmployeeTable2):

  <%

  Option Explicit

  Dim strConnect

  %>



  <% Response.Buffer =3D True %>



  <!--#include file=3D"adovbs.inc"-->

  <!--#include file=3D"DataStore.inc"-->



  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">



  <HTML>

  <HEAD>

  <TITLE>EMPLOYEE MASTER DATABASE - DELETION</TITLE>

  </HEAD>



  <BODY BGCOLOR=3D"FFFF80">

  <CENTER>

  <H1>DELETE EMPLOYEE <BR>FROM MASTER DATABASE</H1>

  </CENTER>





  <%

      Dim dsn, conn, rs, sql

      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 

'"&Session("Firstname")&"') AND (LastName =3D '" & 

Session("LastName")&"'))"

      Response.Write(sql)

      rs.Open sql, conn, 3, 3 

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

          Response.Write(Session("IDNumber"))

         

  rs.Close

  Set rs =3D Nothing



  conn.Close

  Set conn =3D Nothing

  %>



  <%

  Dim objRS, objComm, intNoOfRecords



  If Request.Form("DeleteStatus") =3D "YES" Then



          Set objComm =3D Server.CreateObject("ADODB.Command")



          objComm.ActiveConnection =3D strConnect

          objComm.CommandText =3D "DELETE FROM EmployeeTable WHERE 

((FirstName =3D '"&Session("Firstname")&"') AND (LastName =3D '" & 

Session("LastName")&"'))"

          objComm.CommandType =3D adCmdText

          objComm.Execute intNoOfRecords

          Response.Write "<HR><BR>The DELETE command has been executed, 

"

          Response.Write "Number of records deleted =3D " & 

intNoOfRecords & "<BR>"

          Response.Write "<B><U>YOU HAVE JUST DELETED</U> "

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

          Response.Write " "

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

          Response.Write "<U>FROM THE EMPLOYEE DATABASE.</U></B> "



          Set objComm =3D Nothing

          Response.Redirect "DeleteEmployeeSkillRecords.asp"

  Else

          Response.Redirect "EmployeeMasterMainMenu.asp"

  End If

  %>



  </BODY>

  </HTML>



  Here is my code for the page that is unsuccessful 

(DeleteEmployeeSkillRecords.asp):

  <%

  Option Explicit

  Dim strConnect

  %>



  <!--#include file=3D"adovbs.inc"-->

  <!--#include file=3D"DataStore.inc"-->



  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">



  <HTML>

  <HEAD>

  <TITLE>EMPLOYEE MASTER DATABASE - DELETION</TITLE>

  </HEAD>



  <BODY BGCOLOR=3D"FFFF80">

  <CENTER>

  <H1>DELETING EMPLOYEE SKILL RECORDS<BR>FROM MASTER DATABASE</H1>

  </CENTER>



  <CENTER>

  <%

  Response.Write "<B><H3><EM><U>ATTENTION:</U></EM></H3>"

  Response.Write "<H4>AFTER YOU HAVE <U>DELETED THIS EMPLOYEE'S</U> 

<BR>"

  Response.Write "INDIVIDUAL SKILL RECORDS FROM THE EMPLOYEE'S SKILLS 

TABLE <BR>"

  Response.Write "<U>THERE WILL BE NO REFERENCE'S OF THIS EMPLOYEE 

ANYWHERE IN THIS DATABASE.</U></H4><BR> "

  %>

  </CENTER>



  <%



  'Dim objRS, intNoOfRecords, IDNumber

  'Set objRs =3D Server.CreateObject("ADODB.Recordset")



  'objRS.Open "EmployeeSkillsTable", strConnect, adOpenStatic, 

adLockOptimistic,adCmdTable



  'objRS.Filter =3D "IDNumber =3D '"&(Session("IDNumber")&"')"

  'Response.Write "We are DELETING ALL of the following records:<BR>"

  'While Not objRS.EOF

          'If objRs("IDNumber") =3D Session("IDNumber") Then

                  'Response.Write (objRs("SkillID"))

                  'Response.Write "<BR>"

                  'objRS.Delete

                  'objRS.MoveNext

          'End If

  'Wend



  'objRS.Close

  Dim objComm, intNoOfRecords



  Set objComm =3D Server.CreateObject("ADODB.Command")



  objComm.ActiveConnection =3D strConnect

  objComm.CommandText =3D "DELETE FROM EmployeeTable WHERE (IDNumber =3D 

'"&Session("IDNumber")&"')"

  objComm.CommandType =3D adCmdText

  objComm.Execute intNoOfRecords

  Response.Write "<HR><BR>The DELETE command has been executed,<BR> "

  Response.Write "The IDNumber you just tried to DELETE was "

  Response.Write(Session("IDNumber")

  Response.Write "Number of records deleted =3D " & intNoOfRecords & 

"<BR>"

  Response.Write "<B><U>YOU HAVE JUST DELETED</U> "

  Response.Write (Session("Firstname"))

  Response.Write " "

  Response.Write (Session("Lastname"))

  Response.Write "<U>FROM THE EMPLOYEE DATABASE.</U></B> "



  Set objComm =3D Nothing



  Response.Write "We have DELETED ALL REFERENCES TO "

  Response.Write (Session("FirstName"))

  Response.Write " " 

  Response.Write (Session("LastName"))

  Response.Write " "

  Response.Write "from the <STRONG>EMPLOYEE MASTER DATABASE.</STRONG>"





  Set objComm =3D Nothing

  %>



  </BODY>

  </HTML>



  ---

  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!




leave-asp_databases-$subst('Recip.MemberIDChar')@p2p.wrox.com







---

FREE WEB DEVELOPMENT CODE, CONTENT, AND INSIGHTS

IN YOUR INBOX!

Get the latest and best HTML, XML, and JavaScript 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!  

---

You are currently subscribed to asp_databases as: $subst('Recip.EmailAddr')

To unsubscribe send a blank email to leave-asp_databases-$subst('Recip.MemberIDChar')@p2p.wrox.com








Message #3 by "John P. Parlato" <jparlato@m...> on Wed, 13 Dec 2000 22:32:51 -0500
This is a multi-part message in MIME format.



------=_NextPart_000_001D_01C06554.A07DA160

Content-Type: text/plain;

	charset="us-ascii"

Content-Transfer-Encoding: 7bit



you may need to trim the session variables so that they are exact matches.

Does your code work in the query analyzer?

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

  From: Leo Clayton [mailto:claytonl@z...]

  Sent: Wednesday, December 13, 2000 3:35 PM

  To: ASP Databases

  Subject: [asp_databases] Deleting Records





  Can someone tell me why my attempt to DELETE some records from a TABLE is

not successfully?



  I SELECT a person from a table based upon a name passed from a FORM.  Then

I save the IDNumber in a Session variable, Delete the persons record from

this TABLE (successfully) and go to another page that is supposed to DELETE

all of the records that have an IDNumber =  Session("IDNumber").



  Here is my code for the page that is successful

(DeleteFromEmployeeTable2):

  <%

  Option Explicit

  Dim strConnect

  %>



  <% Response.Buffer = True %>



  <!--#include file="adovbs.inc"-->

  <!--#include file="DataStore.inc"-->



  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">



  <HTML>

  <HEAD>

  <TITLE>EMPLOYEE MASTER DATABASE - DELETION</TITLE>

  </HEAD>



  <BODY BGCOLOR="FFFF80">

  <CENTER>

  <H1>DELETE EMPLOYEE <BR>FROM MASTER DATABASE</H1>

  </CENTER>





  <%

      Dim dsn, conn, rs, sql

      dsn="EmployeeMaster"

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

       conn.Mode=3

      conn.open dsn

      'Set Session("emp_conn") = conn



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



      sql="SELECT IDNumber FROM EmployeeTable WHERE ((FirstName 

'"&Session("Firstname")&"') AND (LastName = '" & Session("LastName")&"'))"

      Response.Write(sql)

      rs.Open sql, conn, 3, 3

          Session("IDNumber") = rs("IDNumber")

          Response.Write(Session("IDNumber"))



  rs.Close

  Set rs = Nothing



  conn.Close

  Set conn = Nothing

  %>



  <%

  Dim objRS, objComm, intNoOfRecords



  If Request.Form("DeleteStatus") = "YES" Then



          Set objComm = Server.CreateObject("ADODB.Command")



          objComm.ActiveConnection = strConnect

          objComm.CommandText = "DELETE FROM EmployeeTable WHERE ((FirstName

= '"&Session("Firstname")&"') AND (LastName = '" & Session("LastName")&"'))"

          objComm.CommandType = adCmdText

          objComm.Execute intNoOfRecords

          Response.Write "<HR><BR>The DELETE command has been executed, "

          Response.Write "Number of records deleted = " & intNoOfRecords &

"<BR>"

          Response.Write "<B><U>YOU HAVE JUST DELETED</U> "

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

          Response.Write " "

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

          Response.Write "<U>FROM THE EMPLOYEE DATABASE.</U></B> "



          Set objComm = Nothing

          Response.Redirect "DeleteEmployeeSkillRecords.asp"

  Else

          Response.Redirect "EmployeeMasterMainMenu.asp"

  End If

  %>



  </BODY>

  </HTML>



  Here is my code for the page that is unsuccessful

(DeleteEmployeeSkillRecords.asp):

  <%

  Option Explicit

  Dim strConnect

  %>



  <!--#include file="adovbs.inc"-->

  <!--#include file="DataStore.inc"-->



  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">



  <HTML>

  <HEAD>

  <TITLE>EMPLOYEE MASTER DATABASE - DELETION</TITLE>

  </HEAD>



  <BODY BGCOLOR="FFFF80">

  <CENTER>

  <H1>DELETING EMPLOYEE SKILL RECORDS<BR>FROM MASTER DATABASE</H1>

  </CENTER>



  <CENTER>

  <%

  Response.Write "<B><H3><EM><U>ATTENTION:</U></EM></H3>"

  Response.Write "<H4>AFTER YOU HAVE <U>DELETED THIS EMPLOYEE'S</U> <BR>"

  Response.Write "INDIVIDUAL SKILL RECORDS FROM THE EMPLOYEE'S SKILLS TABLE

<BR>"

  Response.Write "<U>THERE WILL BE NO REFERENCE'S OF THIS EMPLOYEE ANYWHERE

IN THIS DATABASE.</U></H4><BR> "

  %>

  </CENTER>



  <%



  'Dim objRS, intNoOfRecords, IDNumber

  'Set objRs = Server.CreateObject("ADODB.Recordset")



  'objRS.Open "EmployeeSkillsTable", strConnect, adOpenStatic,

adLockOptimistic,adCmdTable



  'objRS.Filter = "IDNumber = '"&(Session("IDNumber")&"')"

  'Response.Write "We are DELETING ALL of the following records:<BR>"

  'While Not objRS.EOF

          'If objRs("IDNumber") = Session("IDNumber") Then

                  'Response.Write (objRs("SkillID"))

                  'Response.Write "<BR>"

                  'objRS.Delete

                  'objRS.MoveNext

          'End If

  'Wend



  'objRS.Close

  Dim objComm, intNoOfRecords



  Set objComm = Server.CreateObject("ADODB.Command")



  objComm.ActiveConnection = strConnect

  objComm.CommandText = "DELETE FROM EmployeeTable WHERE (IDNumber 

'"&Session("IDNumber")&"')"

  objComm.CommandType = adCmdText

  objComm.Execute intNoOfRecords

  Response.Write "<HR><BR>The DELETE command has been executed,<BR> "

  Response.Write "The IDNumber you just tried to DELETE was "

  Response.Write(Session("IDNumber")

  Response.Write "Number of records deleted = " & intNoOfRecords & "<BR>"

  Response.Write "<B><U>YOU HAVE JUST DELETED</U> "

  Response.Write (Session("Firstname"))

  Response.Write " "

  Response.Write (Session("Lastname"))

  Response.Write "<U>FROM THE EMPLOYEE DATABASE.</U></B> "



  Set objComm = Nothing



  Response.Write "We have DELETED ALL REFERENCES TO "

  Response.Write (Session("FirstName"))

  Response.Write " "

  Response.Write (Session("LastName"))

  Response.Write " "

  Response.Write "from the <STRONG>EMPLOYEE MASTER DATABASE.</STRONG>"





  Set objComm = Nothing

  %>



  </BODY>

  </HTML>



  ---

  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!




leave-asp_databases-$subst('Recip.MemberIDChar')@p2p.wrox.com







--- 

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!  

---

You are currently subscribed to asp_databases as: $subst('Recip.EmailAddr')

To unsubscribe send a blank email to leave-asp_databases-$subst('Recip.MemberIDChar')@p2p.wrox.com








Message #4 by Imar Spaanjaars <Imar@S...> on Thu, 14 Dec 2000 08:57:44 +0100
Leo,



What data type is IDNumber in the database? It sounds like a number but you 

treat it as a string / varchar.

Look at your WHERE clause:



WHERE (IDNumber = '"&Session("IDNumber") & "')"



You have added extra apostrophes around the IDNumber. Try this instead:

WHERE (IDNumber = "&Session("IDNumber") & ")"





HtH



Imar



At 03:35 PM 12/13/2000 -0500, you wrote:

>Can someone tell me why my attempt to DELETE some records from a TABLE is 

>not successfully?

>

>I SELECT a person from a table based upon a name passed from a FORM.  Then 

>I save the IDNumber in a Session variable, Delete the persons record from 

>this TABLE (successfully) and go to another page that is supposed to 

>DELETE all of the records that have an IDNumber =  Session("IDNumber").

>

>Here is my code for the page that is successful (DeleteFromEmployeeTable2):

><%

>Option Explicit

>Dim strConnect

>%>

>

><% Response.Buffer = True %>

>

><!--#include file="adovbs.inc"-->

><!--#include file="DataStore.inc"-->

>

><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

>

><HTML>

><HEAD>

><TITLE>EMPLOYEE MASTER DATABASE - DELETION</TITLE>

></HEAD>

>

><BODY BGCOLOR="FFFF80">

><CENTER>

><H1>DELETE EMPLOYEE <BR>FROM MASTER DATABASE</H1>

></CENTER>

>

>

><%

>     Dim dsn, conn, rs, sql

>     dsn="EmployeeMaster"

>     Set conn = Server.CreateObject("ADODB.Connection")

>      conn.Mode=3

>     conn.open dsn

>     'Set Session("emp_conn") = conn

>

>     Set rs = Server.CreateObject("ADODB.RecordSet")

>

>     sql="SELECT IDNumber FROM EmployeeTable WHERE ((FirstName = 

> '"&Session("Firstname")&"') AND (LastName = '" & Session("LastName")&"'))"

>     Response.Write(sql)

>     rs.Open sql, conn, 3, 3

>         Session("IDNumber") = rs("IDNumber")

>         Response.Write(Session("IDNumber"))

>

>rs.Close

>Set rs = Nothing

>

>conn.Close

>Set conn = Nothing

>%>

>

><%

>Dim objRS, objComm, intNoOfRecords

>

>If Request.Form("DeleteStatus") = "YES" Then

>

>         Set objComm = Server.CreateObject("ADODB.Command")

>

>         objComm.ActiveConnection = strConnect

>         objComm.CommandText = "DELETE FROM EmployeeTable WHERE 

> ((FirstName = '"&Session("Firstname")&"') AND (LastName = '" & 

> Session("LastName")&"'))"

>         objComm.CommandType = adCmdText

>         objComm.Execute intNoOfRecords

>         Response.Write "<HR><BR>The DELETE command has been executed, "

>         Response.Write "Number of records deleted = " & intNoOfRecords & 

> "<BR>"

>         Response.Write "<B><U>YOU HAVE JUST DELETED</U> "

>         Response.Write (Request.Form("Firstname"))

>         Response.Write " "

>         Response.Write (Request.Form("Lastname"))

>         Response.Write "<U>FROM THE EMPLOYEE DATABASE.</U></B> "

>

>         Set objComm = Nothing

>         Response.Redirect "DeleteEmployeeSkillRecords.asp"

>Else

>         Response.Redirect "EmployeeMasterMainMenu.asp"

>End If

>%>

>

></BODY>

></HTML>

>

>Here is my code for the page that is unsuccessful 

>(DeleteEmployeeSkillRecords.asp):

><%

>Option Explicit

>Dim strConnect

>%>

>

><!--#include file="adovbs.inc"-->

><!--#include file="DataStore.inc"-->

>

><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

>

><HTML>

><HEAD>

><TITLE>EMPLOYEE MASTER DATABASE - DELETION</TITLE>

></HEAD>

>

><BODY BGCOLOR="FFFF80">

><CENTER>

><H1>DELETING EMPLOYEE SKILL RECORDS<BR>FROM MASTER DATABASE</H1>

></CENTER>

>

><CENTER>

><%

>Response.Write "<B><H3><EM><U>ATTENTION:</U></EM></H3>"

>Response.Write "<H4>AFTER YOU HAVE <U>DELETED THIS EMPLOYEE'S</U> <BR>"

>Response.Write "INDIVIDUAL SKILL RECORDS FROM THE EMPLOYEE'S SKILLS TABLE 

><BR>"

>Response.Write "<U>THERE WILL BE NO REFERENCE'S OF THIS EMPLOYEE ANYWHERE 

>IN THIS DATABASE.</U></H4><BR> "

>%>

></CENTER>

>

><%

>

>'Dim objRS, intNoOfRecords, IDNumber

>'Set objRs = Server.CreateObject("ADODB.Recordset")

>

>'objRS.Open "EmployeeSkillsTable", strConnect, adOpenStatic, 

>adLockOptimistic,adCmdTable

>

>'objRS.Filter = "IDNumber = '"&(Session("IDNumber")&"')"

>'Response.Write "We are DELETING ALL of the following records:<BR>"

>'While Not objRS.EOF

>         'If objRs("IDNumber") = Session("IDNumber") Then

>                 'Response.Write (objRs("SkillID"))

>                 'Response.Write "<BR>"

>                 'objRS.Delete

>                 'objRS.MoveNext

>         'End If

>'Wend

>

>'objRS.Close

>Dim objComm, intNoOfRecords

>

>Set objComm = Server.CreateObject("ADODB.Command")

>

>objComm.ActiveConnection = strConnect

>objComm.CommandText = "DELETE FROM EmployeeTable WHERE (IDNumber = 

>'"&Session("IDNumber")&"')"

>objComm.CommandType = adCmdText

>objComm.Execute intNoOfRecords

>Response.Write "<HR><BR>The DELETE command has been executed,<BR> "

>Response.Write "The IDNumber you just tried to DELETE was "

>Response.Write(Session("IDNumber")

>Response.Write "Number of records deleted = " & intNoOfRecords & "<BR>"

>Response.Write "<B><U>YOU HAVE JUST DELETED</U> "

>Response.Write (Session("Firstname"))

>Response.Write " "

>Response.Write (Session("Lastname"))

>Response.Write "<U>FROM THE EMPLOYEE DATABASE.</U></B> "

>

>Set objComm = Nothing

>

>Response.Write "We have DELETED ALL REFERENCES TO "

>Response.Write (Session("FirstName"))

>Response.Write " "

>Response.Write (Session("LastName"))

>Response.Write " "

>Response.Write "from the <STRONG>EMPLOYEE MASTER DATABASE.</STRONG>"

>

>

>Set objComm = Nothing

>%>

>

></BODY>

></HTML>

>



---

FREE WEB DEVELOPMENT CODE, CONTENT, AND INSIGHTS

IN YOUR INBOX!

Get the latest and best HTML, XML, and JavaScript 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!  

---

You are currently subscribed to asp_databases as: $subst('Recip.EmailAddr')

To unsubscribe send a blank email to leave-asp_databases-$subst('Recip.MemberIDChar')@p2p.wrox.com


  Return to Index