
Originally Posted by
richyrich
Is it inside some sort of loop?
Executing that SQL query itself wouldn't insert 5 records.
Sorry Rich, I do have a Loop but its at the end of the page, didnt think it would matter? Would it be possible to have a quick look at my code?
Code:
<html>
<body>
<%
showName=request.form("showName")
performanceID=request.form("performanceID")
performance_time=request.form("performance_time")
email=request.form("email")
DIM conn
set conn=Server.CreateObject("ADODB.Connection")
conn.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0"
conn.open server.mappath("../db/database.mdb")
set rs = Server.CreateObject("ADODB.recordset")
'validating the values on the form
sql= "SELECT shows.[showID], shows.[showName], performances.[performance_time] FROM shows INNER JOIN performances ON shows.[showID] = performances.[showID] WHERE shows.[showName]='"& showName & "' AND performances.[performance_time]='"&performance_time & "'"
rs.Open sql, conn
'response.write sql
if rs.EOF Then
Response.Write "<h4 >Oops! No records found!</h4>"
else
do while not rs.EOF
%>
<%
sql="INSERT INTO bookings (performanceID, customerID, bookingDate)"
sql=sql & " VALUES "
sql=sql & "('" & Request.Form("performanceID") & "',"
sql=sql & "'" & Request.Form("customerID") & "',"
sql=sql & "'" & Request.Form("bookingDate") & "');"
sql=sql & "INSERT INTO performances(Status) VALUES('Booked');"
on error resume next
conn.Execute sql,recaffected
'debug the sql statement
response.write sql
'create a new recordset to hold the new data, as we need to run a seperate query to find the bookingID
set rs2 = Server.CreateObject("ADODB.recordset")
sql2 = "SELECT @@Identity"
set rs2 = conn.execute(sql2)
bookingID = "Your Booking Number is: " & rs2(0)
response.write rs2(0)
if err<>0 then
Response.Write("No update permissions!")
else
Response.Write("<h3>" & recaffected & " record added and email sent</h3>")
end if
%>
<%
rs.movenext
loop
rs.close
rs2.close
conn.close
end if
%>
</body>
</html>
Bookmarks