operation is not allowed when the object is close
Line 136 shows me an error. I will appreciate your help. Since I am new to ASP. Explain me in detail.
'ASP Header
'Option Explicit
Response.Buffer=true
Response.Expires=-1
Dim oConnection
Dim oRecordset
Dim oCommand
Dim oEmployeeName
const sDataBaseConnectionString= "
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
oEmployeeName.Open SQL,oConnection
if not oEmployeeName.EOF then
strName =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>
|