473,508 Members | 2,360 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

i think problem lies with SQL statement, please view and assist

66 New Member
Hi all,

im nearly there with this one and im sure it shouldnt be hard to solve, i just cant seem to find the solution.

ive got records being displayed, the user can then tick what records to delete... click delete.. it shows deleted records then you can go back to the screen, It works if one record is selected but any more it doesnt delete any so im sure there is a problem with my SQL statement.

the code for the 2 pages have been shown below:

The code for the selection page
=======================
Expand|Select|Wrap|Line Numbers
  1.         <%
  2. If rssearchcnx.BOF and rssearchcnx.EOF Then%> 
  3.     We appolagise, but no flights were found matching your search
  4.       </div>
  5.       <p align="center"><a href="search.asp" target="mainFrame">please try again</a></p>
  6. <%Else%>
  7.  
  8. <%If Not rssearchcnx.BOF Then%>
  9. <%
  10.     Do While Not rssearchcnx.EOF
  11.     %>
  12. <tr>
  13.         <td ><%=rssearchcnx("flight_id")%></td>
  14.         <td><form name="update" method="post" action="flight_update.asp"><input type="hidden" value="<%=(rssearchcnx.Fields.Item("flight_id").Value)%>" name="flight_id" /><input type="submit" value="update" /></form></td>
  15.         <td><form name="form" method="post" action="delete.asp"><input type="checkbox" name="flight_id" value="<%=(rssearchcnx.Fields.Item("flight_id").Value)%>"></td>
  16.  
  17.       </tr>
  18.     <% rssearchcnx.MoveNext
  19.     Loop
  20.     %>
  21.  
  22. </table>
  23.  
  24. <%End If%>
  25. <%End If%>
  26.     <input type="submit" value="Delete Selected Records">
  27. </form>
  28. <%
  29. rssearchcnx.Close
  30. searchcnx.Close
  31. %>
  32.  
  33.  
code for the delete action page
======================
Expand|Select|Wrap|Line Numbers
  1. <%
  2.  
  3. Dim flight_id
  4.  
  5. flight_id = Request.Form("flight_id")
  6.  
  7.  
  8. SQL="DELETE * FROM tbl_flight_details WHERE flight_id ='"+Request.Form("flight_id")+"'"
  9.  
  10.  Set MyConn=Server.CreateObject("ADODB.Connection")
  11. MyConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\inetpub\wwwroot\ddwassignment3\airlines.mdb"
  12.  
  13. Set MyRS=Server.CreateObject("ADODB.RecordSet")
  14. MyRS.Open SQL,MyConn
  15.  
  16. %>
  17.  
  18. </p>
  19.       <table width="37%" border="0" align="center">
  20.         <tr>
  21. <td align="center"><% Response.Write("<font face=Calibri>You have deleted flight number <B><font face=Calibri color=Red>" & flight_id)%></font></B></td>
  22.  
any help will be MUCH appreciated

kind regards

jason
Mar 10 '08 #1
8 1472
amitpatel66
2,367 Recognized Expert Top Contributor
Hi all,

im nearly there with this one and im sure it shouldnt be hard to solve, i just cant seem to find the solution.

ive got records being displayed, the user can then tick what records to delete... click delete.. it shows deleted records then you can go back to the screen, It works if one record is selected but any more it doesnt delete any so im sure there is a problem with my SQL statement.

the code for the 2 pages have been shown below:

The code for the selection page
=======================
Expand|Select|Wrap|Line Numbers
  1.         <%
  2. If rssearchcnx.BOF and rssearchcnx.EOF Then%> 
  3.     We appolagise, but no flights were found matching your search
  4.       </div>
  5.       <p align="center"><a href="search.asp" target="mainFrame">please try again</a></p>
  6. <%Else%>
  7.  
  8. <%If Not rssearchcnx.BOF Then%>
  9. <%
  10.     Do While Not rssearchcnx.EOF
  11.     %>
  12. <tr>
  13.         <td ><%=rssearchcnx("flight_id")%></td>
  14.         <td><form name="update" method="post" action="flight_update.asp"><input type="hidden" value="<%=(rssearchcnx.Fields.Item("flight_id").Value)%>" name="flight_id" /><input type="submit" value="update" /></form></td>
  15.         <td><form name="form" method="post" action="delete.asp"><input type="checkbox" name="flight_id" value="<%=(rssearchcnx.Fields.Item("flight_id").Value)%>"></td>
  16.  
  17.       </tr>
  18.     <% rssearchcnx.MoveNext
  19.     Loop
  20.     %>
  21.  
  22. </table>
  23.  
  24. <%End If%>
  25. <%End If%>
  26.     <input type="submit" value="Delete Selected Records">
  27. </form>
  28. <%
  29. rssearchcnx.Close
  30. searchcnx.Close
  31. %>
  32.  
  33.  
code for the delete action page
======================
Expand|Select|Wrap|Line Numbers
  1. <%
  2.  
  3. Dim flight_id
  4.  
  5. flight_id = Request.Form("flight_id")
  6.  
  7.  
  8. SQL="DELETE * FROM tbl_flight_details WHERE flight_id ='"+Request.Form("flight_id")+"'"
  9.  
  10.  Set MyConn=Server.CreateObject("ADODB.Connection")
  11. MyConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\inetpub\wwwroot\ddwassignment3\airlines.mdb"
  12.  
  13. Set MyRS=Server.CreateObject("ADODB.RecordSet")
  14. MyRS.Open SQL,MyConn
  15.  
  16. %>
  17.  
  18. </p>
  19.       <table width="37%" border="0" align="center">
  20.         <tr>
  21. <td align="center"><% Response.Write("<font face=Calibri>You have deleted flight number <B><font face=Calibri color=Red>" & flight_id)%></font></B></td>
  22.  
any help will be MUCH appreciated

kind regards

jason
Does the below line stores all the values selected from front end and in what format? either comma delimited or something else??
flight_id = Request.Form("flight_id")
Mar 10 '08 #2
ronverdonk
4,258 Recognized Expert Specialist
When I look at the logic of the script I see that, within each loop, a form with checkbox is created but only after the loop a SUBMIT is created. So hitting the SUBMIT will only submit one form with one checkbox.

Ronald
Mar 10 '08 #3
jasone
66 New Member
Does the below line stores all the values selected from front end and in what format? either comma delimited or something else??
flight_id = Request.Form("flight_id")
Hi, im unsure of this, is there anyway to check
Mar 10 '08 #4
amitpatel66
2,367 Recognized Expert Top Contributor
Hi, im unsure of this, is there anyway to check
Try printing your variable value in the front end (IE) using PHP after assigning a value to it.
And post back here for reference
Mar 10 '08 #5
jasone
66 New Member
Try printing your variable value in the front end (IE) using PHP after assigning a value to it.
And post back here for reference
Hey, i finally go the values selected to be printed out in the variable "flight_id" and it shows all the ones selected, seperated with a comma.

whats the next step to get this working? :-S
Mar 10 '08 #6
jasone
66 New Member
i have changed the form code slightly to the one shown below :

Expand|Select|Wrap|Line Numbers
  1. <form name="delete" method="GEt" action="delete.asp?flight_id=<%=(rssearchcnx.Fields.Item("flight_id").Value)%>" >
  2.  
  3.  
Mar 10 '08 #7
jasone
66 New Member
so im guessing i just need to write a loop now to delete each one... any ideas on how to wrote this... anyone?
Mar 10 '08 #8
amitpatel66
2,367 Recognized Expert Top Contributor
so im guessing i just need to write a loop now to delete each one... any ideas on how to wrote this... anyone?
No LOOP is not required. You can try something like this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. SQL="DELETE * FROM tbl_flight_details WHERE flight_id IN ("+Request.Form("flight_id")+")"
  3.  
  4.  
Mar 11 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

8
1273
by: dark.saintzero | last post by:
Please i would like someone to assist me. I am new to the SQL and how to use it...I need to know how to efficiently use the SELECT statement through error messages from our server. I look forward...
30
6367
by: Mark | last post by:
I am a complete novice with php scrip but I am wiling to learn. I am in need of some help, please. Can anyone sort this code out for me so that it works correctly and adjusts the price for the...
4
1173
by: Lerp | last post by:
Hi, I have this sub in which I am trying to get a client name from a second table based on a clientid value in my datalist. I am having problems grabbing the clientid value out of my datalist...
6
2228
by: sghi | last post by:
Hi All, I'm new to this group and quite new to access/vba. So, shortly after beginning to write a simple application for my wife, I came across a blocking problem: I need to intercept the sql...
14
3081
by: Matt | last post by:
I need to add the following variable into an SQL statement and not sure how to do it. strGCID needs to be inserted into the following statement: SQL = "SELECT tblContacts.* FROM tblContacts...
4
2970
by: mike_dba | last post by:
Can someone assist in decoding the values returned from the snapshot statement table function ? Specifically, I am looking to relate the numerical values of stmt_operation column to a literal. ...
2
13432
by: juan.gautier | last post by:
Hi, I try to construct a SQL code for a view to select a specific data from a table, this query take the value of the filter from a text box in a visual basic 6.0 form. my problem is when i...
1
1822
by: itsraghz | last post by:
Hello All, I am using a Dynamic SQL Statement inside a Stored Procedure. I am using IBM DB2 V8.1 database. When i want to have the values to be filled in dynamically, i use the parameter...
4
1509
by: cyborg81 | last post by:
when i compile the following code it gives the following error on the line indicated in bold: #include<iostream> #include<iomanip> #include<cstdlib> using std::cin; using std::cout;
0
7223
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7377
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7489
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4705
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1547
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
414
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.