robojob
04-11-2006, 12:34 PM
I have a form for a booking system, on the form you enter the date in the format 11/04/2006 and when ready click submit. The process page should lookup the date in the calendar table and insert the corresponding id for that date.
I have the below code but its throwing up this error:
Error Type:
ADODB.Recordset (0x800A0CC1)
Item cannot be found in the collection corresponding to the requested name or ordinal.
/add.asp, line 28
but i know the record is there!! any ideas..?
<%
DIM objConn
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
Server.MapPath ("bookings.mdb") & ";"
objConn.Open
DIM mySQL
Dim dateid
dateid = Request.Form("date1")
mySQL = "SELECT * from cal where date = " & dateid & " ;"
DIM objRS
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open mySQL, objConn
'declare your variables
Dim date2, roombooked1, from1, to1, name1, eventname1, address1, phone1, price1, equipment1, layout1, caretaking1, insurance1, riskass1, other1, start1, end1, invnum1
Dim sConnString, connection, sSQL
'Receiving values from Form, assign the values entered to variables
date2 =objRS("cal.id")
roombooked1 =Request.Form("roombooked")
from1 =Request.Form("from")
to1 =Request.Form("to")
name1 =Request.Form("name")
eventname1 =Request.Form("eventname")
address1 =Request.Form("address")
phone1 =Request.Form("phone")
price1 =Request.Form("price")
equipment1 =Request.Form("equipment")
layout1 =Request.Form("layout")
caretaking1 =Request.Form("caretaking")
insurance1 =Request.Form("insurance")
riskass1 =Request.Form("riskass")
other1 =Request.Form("other")
start1 =Request.Form("start1")
end1 =Request.Form("end1")
invnum1 =Request.Form("invnum1")
'declare SQL statement that will query the database
sSQL = "INSERT into bookings (date1, roombooked1, name1, eventname1, address1, phone1, price1, equipment1, layout1, caretaking1, insurance1, riskass1, other1, start1, end1, invnum1) values ('" & _
date2 & "', '" & roombooked1 & "', '" & name1 & "', '" & eventname1 & "', '" & address1 & "', '" & phone1 & "', '" & price1 & "', '" & equipment1 & "', '" & layout1 & "', '" & caretaking1 & "', '" & insurance1 & "', '" & riskass1 & "', '" & other1 & "', '" & start1 & "', '" & end1 & "', '" & invnum1 & "')"
'define the connection string, specify database
'driver and the location of database
sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("bookings.mdb")
'create an ADO connection object
Set connection = Server.CreateObject("ADODB.Connection")
'Open the connection to the database
connection.Open(sConnString)
'execute the SQL
connection.execute(sSQL)
response.redirect "main.asp"
'Done. Close the connection object
connection.Close
Set connection = Nothing
%>
I have the below code but its throwing up this error:
Error Type:
ADODB.Recordset (0x800A0CC1)
Item cannot be found in the collection corresponding to the requested name or ordinal.
/add.asp, line 28
but i know the record is there!! any ideas..?
<%
DIM objConn
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
Server.MapPath ("bookings.mdb") & ";"
objConn.Open
DIM mySQL
Dim dateid
dateid = Request.Form("date1")
mySQL = "SELECT * from cal where date = " & dateid & " ;"
DIM objRS
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open mySQL, objConn
'declare your variables
Dim date2, roombooked1, from1, to1, name1, eventname1, address1, phone1, price1, equipment1, layout1, caretaking1, insurance1, riskass1, other1, start1, end1, invnum1
Dim sConnString, connection, sSQL
'Receiving values from Form, assign the values entered to variables
date2 =objRS("cal.id")
roombooked1 =Request.Form("roombooked")
from1 =Request.Form("from")
to1 =Request.Form("to")
name1 =Request.Form("name")
eventname1 =Request.Form("eventname")
address1 =Request.Form("address")
phone1 =Request.Form("phone")
price1 =Request.Form("price")
equipment1 =Request.Form("equipment")
layout1 =Request.Form("layout")
caretaking1 =Request.Form("caretaking")
insurance1 =Request.Form("insurance")
riskass1 =Request.Form("riskass")
other1 =Request.Form("other")
start1 =Request.Form("start1")
end1 =Request.Form("end1")
invnum1 =Request.Form("invnum1")
'declare SQL statement that will query the database
sSQL = "INSERT into bookings (date1, roombooked1, name1, eventname1, address1, phone1, price1, equipment1, layout1, caretaking1, insurance1, riskass1, other1, start1, end1, invnum1) values ('" & _
date2 & "', '" & roombooked1 & "', '" & name1 & "', '" & eventname1 & "', '" & address1 & "', '" & phone1 & "', '" & price1 & "', '" & equipment1 & "', '" & layout1 & "', '" & caretaking1 & "', '" & insurance1 & "', '" & riskass1 & "', '" & other1 & "', '" & start1 & "', '" & end1 & "', '" & invnum1 & "')"
'define the connection string, specify database
'driver and the location of database
sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("bookings.mdb")
'create an ADO connection object
Set connection = Server.CreateObject("ADODB.Connection")
'Open the connection to the database
connection.Open(sConnString)
'execute the SQL
connection.execute(sSQL)
response.redirect "main.asp"
'Done. Close the connection object
connection.Close
Set connection = Nothing
%>