Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 25th, 2004, 11:19 PM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 119
Thanks: 0
Thanked 0 Times in 0 Posts
Default operation is not allowed when object is closed

I am trying to get fullName of an Employee, but gives me an error. When i decooment OPtion expilict it gives me an errror "expected" Please help me here after looking the code. line 136 if not oEmployeeeName.EOF Thanks

'ASP Header
 'Option Explicit
 Response.Buffer=true
 Response.Expires=-1

 Dim oConnection
 Dim oRecordset
 Dim oCommand
 Dim oEmployeeName

 const sDataBaseConnectionString= "DATABASE=HR2000_T;DSN=shoakatdb;UID=shoakat;Passw ord=password"
 Dim mode

mode=Request.Form("hdnMode")
If mode= "" Then ' default value is blank
 mode = "Select"
End if

Select Case mode
Case "Select"
      Call FetchEmployeeInfo()
      Call FetchEmployeeName()

Case "Delete"
    Call DeleteEmployee()
    Call FetchEmployeeInfo()

Case "Insert"
  Call InsertEmployee()
  Call FetchEmployeeInfo()

Case "Update"
 Call UpdateEmployee()
 Call FetchEmployeeInfo()


End Select

Sub FetchEmployeeInfo()
'Database Connection String
On Error Resume Next
Set oConnection=Server.CreateObject("ADODB.Connection" )
oConnection.ConnectionString=sDataBaseConnectionSt ring
oConnection.Open 'Connect to the databse
If Err.number <> 0 Then
 Response.Write("Problem establishing Database connection")
 'Response.End
End If
Set oCommand = Server.CreateObject("ADODB.Command")
oCommand.ActiveConnection=oConnection
oCommand.CommandType=4
oCommand.CommandText="spp_CustRate"
set objParam1=objCmd.CreateParameter("@iEmpID",3,1,12)
set objParam2=objCmd.CreateParameter("@iSubcontID",3,1 ,12)
set objParam3=objCmd.CreateParameter("@iTaskID",3,1,12 )
set objParam4=objCmd.CreateParameter("@iProjDetID",3,1 ,12)
oCommand.Parameters.Append(objParam1)
oCommand.Parameters.Append(objParam2)
oCommand.Parameters.Append(objParam3)
oCommand.Parameters.Append(objParam4)
if (iEmpID ="")then
    objParam1.value=null

else
    objParam1.value=iEmpID
end if

if (iSubcontID="")then
    objParam2.value=null

else
    objParam2.value=iSubcontID
end if

if (iTaskID="")then
    objParam3.value =null

else
    objParam3.value =iTaskID
end if
if (iProjDetID="")then
    objParam4.value =null

else
    objParam4.value =iProjDetID
end if
'Response.Write oCommand.CommandText
Set oRecordset= oCommand
End Sub

Sub FetchEmployeeName()
on Error Resume Next
Set oConnection=Server.CreateObject("ADODB.Connection" )
oConnection.ConnectionString=sDataBaseConnectionSt ring
oConnection.Open
If Err.number <> 0 Then
 Response.Write("Problem establishing Database connection")
 'Response.End
End If

set oCommand=Server.CreateObject("ADODB.Command")
oCommand.ActiveConnection=oConnection
oCommand.CommandType=1
oCommand.CommandText= BuildEmployeeName()
Response.Write oCommand.CommandText
oCommand.Execute

End Sub

 Function BuildEmployeeName()
 Dim ResType
 Dim iSubcontID
 Dim iTaskID
 Dim iEmpID
 Dim iProjDetID
 set oEmployeeName=Server.CreateObject("ADODB.Recordset ")

 if ResType="E" then
 iTaskID=383 and iEmpID =743 and iProjDetID =2981
 else
 iSubcontID =26 and iTaskID=157 and iProjDetID =2981
 end if

 Dim SQL
  if ResType= "E" then
    SQL="Select vsEmpFirstName+ ',' +vsEmpLastName As vsName from tblEmployeeInformation where iEmpId=" &cstr(iEmpID)
else
    SQL="Select vsEmpFirstName+ ','+ vsEmpLastName As vsName from tblSubCont where iSubcontId=" &cstr(iSubcontID)
end if
if not oEmployeeName.EOF thenstrName =oEmployeeName.Fields("vsName")
'BuildEmployeeName=strName
end if
oEmployeeName.MoveNext()
BuildEmployeeName=strName
End Function





 %>
 <html>
<Head>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<Script language="JavaScript">


function HandleSave(){ "<TABLE Align = 'center' width ='250px'>"+
"<TR><TD><Input type ='text' name='txtRate1'></TR></TD>"+ "<TR><TD><Input type ='text' name='txtRate2'></TR></TD>" +
"<TR><TD><input type ='text' name='txtEmployee'></TR></TD>"
"</TABLE>"
document.frmMain.submit();
}


</Script>

<Body>

<Form name="frmMain" method="post" action="rateHistory.asp">
<Input type='hidden' name='hdnMode' value=''>
<Input type= 'button' name='Save button' value='Save' onClick=" HandleSave();">
<Input type ='text' name =txtFName value='<%=BuildEmployeeName%>'>
</Form>
</Body>
</HTML>

 
Old November 26th, 2004, 12:17 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 363
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hello,

  You formed sql statement(SQL) but u didnt issue,

  oEmployeeName.open sql,conn


You check that.



-----------
Rajani






Similar Threads
Thread Thread Starter Forum Replies Last Post
Operation is not allowed when obejct is closed zazo XSLT 19 July 25th, 2008 01:26 PM
Operation is not allowed when the object is closed lightmaker Classic ASP Basics 1 June 6th, 2008 12:29 PM
Operation is not allowed when the object is closed kingroon Classic ASP Databases 2 February 5th, 2008 10:29 AM
"OPERATION NOT ALLOWED AFTERRESULT SET IS CLOSED" picky JSP Basics 3 October 12th, 2006 03:26 PM
Operation is not allowed when the object is closed kah Javascript How-To 2 February 16th, 2005 07:20 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.