469,607 Members | 2,068 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,607 developers. It's quick & easy.

ASP Error

I am creating an asp programm for our employee leaves tracking... i am getting this error ADODB.Recordset (0x800A0E7D)
The connection cannot be used to perform this operation. It is either closed or invalid in this context.
/leave/add_to_leave.asp, line 16


here is the code:

<%

'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsdata 'Holds the recordset for the new record to be added to the database
Dim strSQL 'Holds the SQL query for the database

Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("leave.mdb")

Set rsdata = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT leave.UserID, leave.Name, leave.Workgroup, leave.FromDate, leave.ToDate, leave.LeaveType, leave.Reason,leave.FromTime, leave.ToTime, leave.Reason FROM leave;"

rsdata.CursorType = 2
rsdata.LockType = 3
rsdata.Open strSQL

rsdata.AddNew

'Add a new record to the recordset
rsdata.Fields("UserID") = Request.Form("userid")
rsdata.Fields("Name") = Request.Form("name")
rsdata.Fields("Workgroup") = Request.Form("workgroup")
rsdata.Fields("TeamLeader") = Request.Form("TeamLeader")
rsdata.Fields("ContactNumber") = Request.Form("ContactNumber")
rsdata.Fields("FromDate") = Request.Form("FromDate")
rsdata.Fields("ToDate") = Request.Form("ToDate")
rsdata.Fields("LeaveType") = Request.Form("LeaveType")
rsdata.Fields("FromTime") = Request.Form("FromTime")
rsdata.Fields("ToTime") = Request.Form("ToTime")
rsdata.Fields("Reason") = Request.Form("Reason")

rsdata.Update

'Reset server objects
rsdata.Close
Set rsData = Nothing
Set adoCon = Nothing

'Redirect to the leave.asp page
Response.Redirect "leave_form.htm"
%>
Apr 22 '06 #1
0 2091

Post your reply

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

Similar topics

2 posts views Thread by Gregory | last post: by
7 posts views Thread by p | last post: by
3 posts views Thread by Manuel | last post: by
1 post views Thread by developer | last post: by
reply views Thread by mchuc7719 | last post: by
reply views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.