|
 |
aspx thread: Operation is not allowed when the object is closed.
Message #1 by "Brandy" <brandmo@h...> on Fri, 26 Jan 2001 14:41:01 +0100
|
|
I want to create a table where I get a view of my data for editing, the only
method I have found to do this with is with recordset, but its not quite
working completely..
I get an error :
Operation is not allowed when the object is closed.
Anyone who is able to see what is worng in my code or if I could have done
this on a easier way with for instance dataset??
Brandy
Ps : have pasted the code under..
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SQL" %>
<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft FrontPage 4.0">
</HEAD>
<script language=VB id=Script1 runat="server">
Sub Page_Load(Src As Object, E As EventArgs)
dim strProsjektID, strBeskrivelse,strTeknikerID,strFrist ,strProsjekt
strProsjektID=Request.Form("cboProsjektID")
conn = Server.CreateObject("ADODB.Connection")
rs = Server.CreateObject("ADODB.Recordset")
connString = ("provider=SQLOLEDB;data
source=knutepunktet;uid=sa;pwd=;database=sak")
Conn.ConnectionString = connString
conn.Open (, , , adAsyncConnect)
rs.Close
rs=nothing
conn.Close
conn=nothing
end sub
</SCRIPT>
<BODY>
<FORM id=Form1 action=result.aspx method=post runat="server">
<%
rs = Server.CreateObject("ADODB.Recordset")
if rs.EOF then
Response.Write ("Ingen records.")
else
Response.Write ("<table border=""2"" width=""100%"">")
Response.Write ("<tr><th align=""left"" width=""40%"">ProsjektID </th>")
Response.Write ("<th align=""left"" width=""15%"">Beskrivelse </th>")
Response.Write ("<th align=""left"" width=""20%"">TeknikerID </th>")
Response.Write ("<th align=""left"" width=""15%"">Frist </th>")
Response.Write ("<th align=""left"" width=""5%"">Prosjekt </th>")
Response.Write ("</tr>")
do until rs.eof
Response.Write ("<td><div style=""cursor:hand;Color:blue""
onclick=""newWindow('" & rs("ProsjektID") & "')"" ><u>" & rs("ProsjektID") &
"</u></div></td>")
Response.Write ("<td>" & rs("Beskrivelse") & "</td>")
Response.Write ("<td>" & rs("TeknikerID") & "</td>")
Response.Write ("<td>" & rs("Frist") & "</td>")
Response.Write ("<td>" & rs("Prosjekt") & "</td>")
Response.Write ("</tr>")
rs.MoveNext
loop
Response.Write ("</table>")
end if
%>
</form>
</BODY>
</html >
<SCRIPT LANGUAGE=javascript>
<!--
function newWindow(req) {
window.open("rediger.asp?projID='" + req +
"'","Beskrivelse","toolbar=0,location=0,directories=0,status=0,menubar=0,scr
ollbars=0,resizable=1,width=400,height=300")
}
//-->
</SCRIPT>
Message #2 by Igor Braginsky <anhel11@y...> on Fri, 26 Jan 2001 09:59:39 -0800 (PST)
|
|
Because your "adodb.connection" is closed in your sub
Page_load, your receive the error message.
Try to create the adodb.connection and the
adodb.recordset without subroutine. Or close the
adodb.connection at the end of the page not inside of
the subroutine.
Igor
--- Brandy <brandmo@h...> wrote:
> I want to create a table where I get a view of my
> data for editing, the only
> method I have found to do this with is with
> recordset, but its not quite
> working completely..
>
> I get an error :
> Operation is not allowed when the object is closed.
>
> Anyone who is able to see what is worng in my code
> or if I could have done
> this on a easier way with for instance dataset??
>
> Brandy
>
> Ps : have pasted the code under..
>
> <%@ Import Namespace="System.Data" %>
> <%@ Import Namespace="System.Data.SQL" %>
> <%@ Language=VBScript %>
> <HTML>
> <HEAD>
> <META NAME="GENERATOR" Content="Microsoft FrontPage
> 4.0">
> </HEAD>
> <script language=VB id=Script1 runat="server">
>
> Sub Page_Load(Src As Object, E As EventArgs)
>
> dim strProsjektID,
> strBeskrivelse,strTeknikerID,strFrist ,strProsjekt
> strProsjektID=Request.Form("cboProsjektID")
>
>
>
> conn = Server.CreateObject("ADODB.Connection")
> rs = Server.CreateObject("ADODB.Recordset")
> connString = ("provider=SQLOLEDB;data
> source=knutepunktet;uid=sa;pwd=;database=sak")
> Conn.ConnectionString = connString
> conn.Open (, , , adAsyncConnect)
>
> rs.Close
> rs=nothing
> conn.Close
> conn=nothing
>
>
> end sub
>
> </SCRIPT>
>
> <BODY>
> <FORM id=Form1 action=result.aspx method=post
> runat="server">
> <%
> rs = Server.CreateObject("ADODB.Recordset")
>
> if rs.EOF then
> Response.Write ("Ingen records.")
> else
>
> Response.Write ("<table border=""2""
> width=""100%"">")
> Response.Write ("<tr><th align=""left""
> width=""40%"">ProsjektID </th>")
> Response.Write ("<th align=""left""
> width=""15%"">Beskrivelse </th>")
> Response.Write ("<th align=""left""
> width=""20%"">TeknikerID </th>")
> Response.Write ("<th align=""left""
> width=""15%"">Frist </th>")
> Response.Write ("<th align=""left""
> width=""5%"">Prosjekt </th>")
> Response.Write ("</tr>")
> do until rs.eof
> Response.Write ("<td><div
> style=""cursor:hand;Color:blue""
> onclick=""newWindow('" & rs("ProsjektID") & "')""
> ><u>" & rs("ProsjektID") &
> "</u></div></td>")
> Response.Write ("<td>" & rs("Beskrivelse") &
> "</td>")
> Response.Write ("<td>" & rs("TeknikerID") &
> "</td>")
> Response.Write ("<td>" & rs("Frist") & "</td>")
> Response.Write ("<td>" & rs("Prosjekt") & "</td>")
> Response.Write ("</tr>")
> rs.MoveNext
> loop
> Response.Write ("</table>")
>
> end if
> %>
> </form>
>
>
> </BODY>
> </html >
>
>
>
> <SCRIPT LANGUAGE=javascript>
> <!--
>
> function newWindow(req) {
>
> window.open("rediger.asp?projID='" + req +
>
"'","Beskrivelse","toolbar=0,location=0,directories=0,status=0,menubar=0,scr
> ollbars=0,resizable=1,width=400,height=300")
>
>
> }
> //-->
> </SCRIPT>
>
>
Message #3 by John Pirkey <mailjohnny101@y...> on Sat, 27 Jan 2001 03:52:17 -0800 (PST)
|
|
i hope that you just left out the code you used to declare your connection objects
and such. also, you are aware that ASP.Net is strongly typed now, right? so,
dim strProsjektID, strBeskrivelse,strTeknikerID,strFrist ,strProsjekt
is going to create five variants, when they should probably be:
dim strProsjektID as string, strBeskrivelse as string,strTeknikerID as
string,strFrist as string, strProsjekt as string
also, the Language directive changed. you need to add "Page " and change VBScript -
it's actually
<%@ Page Language="VB" %>
now. this could definitely have an effect on how your code is working.
john
--- Brandy <brandmo@h...> wrote:
> I want to create a table where I get a view of my data for editing, the only
> method I have found to do this with is with recordset, but its not quite
> working completely..
>
> I get an error :
> Operation is not allowed when the object is closed.
>
> Anyone who is able to see what is worng in my code or if I could have done
> this on a easier way with for instance dataset??
>
> Brandy
>
> Ps : have pasted the code under..
>
> <%@ Import Namespace="System.Data" %>
> <%@ Import Namespace="System.Data.SQL" %>
> <%@ Language=VBScript %>
> <HTML>
> <HEAD>
> <META NAME="GENERATOR" Content="Microsoft FrontPage 4.0">
> </HEAD>
> <script language=VB id=Script1 runat="server">
>
> Sub Page_Load(Src As Object, E As EventArgs)
>
> dim strProsjektID, strBeskrivelse,strTeknikerID,strFrist ,strProsjekt
> strProsjektID=Request.Form("cboProsjektID")
>
>
>
> conn = Server.CreateObject("ADODB.Connection")
> rs = Server.CreateObject("ADODB.Recordset")
> connString = ("provider=SQLOLEDB;data
> source=knutepunktet;uid=sa;pwd=;database=sak")
> Conn.ConnectionString = connString
> conn.Open (, , , adAsyncConnect)
>
> rs.Close
> rs=nothing
> conn.Close
> conn=nothing
>
>
> end sub
>
> </SCRIPT>
>
> <BODY>
> <FORM id=Form1 action=result.aspx method=post runat="server">
> <%
> rs = Server.CreateObject("ADODB.Recordset")
>
> if rs.EOF then
> Response.Write ("Ingen records.")
> else
>
> Response.Write ("<table border=""2"" width=""100%"">")
> Response.Write ("<tr><th align=""left"" width=""40%"">ProsjektID </th>")
> Response.Write ("<th align=""left"" width=""15%"">Beskrivelse </th>")
> Response.Write ("<th align=""left"" width=""20%"">TeknikerID </th>")
> Response.Write ("<th align=""left"" width=""15%"">Frist </th>")
> Response.Write ("<th align=""left"" width=""5%"">Prosjekt </th>")
> Response.Write ("</tr>")
> do until rs.eof
> Response.Write ("<td><div style=""cursor:hand;Color:blue""
> onclick=""newWindow('" & rs("ProsjektID") & "')"" ><u>" & rs("ProsjektID") &
> "</u></div></td>")
> Response.Write ("<td>" & rs("Beskrivelse") & "</td>")
> Response.Write ("<td>" & rs("TeknikerID") & "</td>")
> Response.Write ("<td>" & rs("Frist") & "</td>")
> Response.Write ("<td>" & rs("Prosjekt") & "</td>")
> Response.Write ("</tr>")
> rs.MoveNext
> loop
> Response.Write ("</table>")
>
> end if
> %>
> </form>
>
>
> </BODY>
> </html >
>
>
>
> <SCRIPT LANGUAGE=javascript>
> <!--
>
> function newWindow(req) {
>
> window.open("rediger.asp?projID='" + req +
> "'","Beskrivelse","toolbar=0,location=0,directories=0,status=0,menubar=0,scr
> ollbars=0,resizable=1,width=400,height=300")
>
>
> }
> //-->
> </SCRIPT>
>
=====
----------------------------
John Pirkey
MCSD
John@S...
http://www.stlvbug.org
Message #4 by Quintis Venter <quintisv@u...> on Mon, 29 Jan 2001 09:47:49 +0200
|
|
Move the following lines to the bottom (after the last 'rs' item is
accessed):
rs.Close
rs=nothing
conn.Close
conn=nothing
Let me know if this helps..
Regards
Quintis
-----Original Message-----
From: Brandy [mailto:brandmo@h...]
Sent: 26 January 2001 03:41
To: ASP+
Subject: [aspx] Operation is not allowed when the object is closed.
I want to create a table where I get a view of my data for editing, the only
method I have found to do this with is with recordset, but its not quite
working completely..
I get an error :
Operation is not allowed when the object is closed.
Anyone who is able to see what is worng in my code or if I could have done
this on a easier way with for instance dataset??
Brandy
Ps : have pasted the code under..
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SQL" %>
<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft FrontPage 4.0">
</HEAD>
<script language=VB id=Script1 runat="server">
Sub Page_Load(Src As Object, E As EventArgs)
dim strProsjektID, strBeskrivelse,strTeknikerID,strFrist ,strProsjekt
strProsjektID=Request.Form("cboProsjektID")
conn = Server.CreateObject("ADODB.Connection")
rs = Server.CreateObject("ADODB.Recordset")
connString = ("provider=SQLOLEDB;data
source=knutepunktet;uid=sa;pwd=;database=sak")
Conn.ConnectionString = connString
conn.Open (, , , adAsyncConnect)
rs.Close
rs=nothing
conn.Close
conn=nothing
end sub
</SCRIPT>
<BODY>
<FORM id=Form1 action=result.aspx method=post runat="server">
<%
rs = Server.CreateObject("ADODB.Recordset")
if rs.EOF then
Response.Write ("Ingen records.")
else
Response.Write ("<table border=""2"" width=""100%"">")
Response.Write ("<tr><th align=""left"" width=""40%"">ProsjektID </th>")
Response.Write ("<th align=""left"" width=""15%"">Beskrivelse </th>")
Response.Write ("<th align=""left"" width=""20%"">TeknikerID </th>")
Response.Write ("<th align=""left"" width=""15%"">Frist </th>")
Response.Write ("<th align=""left"" width=""5%"">Prosjekt </th>")
Response.Write ("</tr>")
do until rs.eof
Response.Write ("<td><div style=""cursor:hand;Color:blue""
onclick=""newWindow('" & rs("ProsjektID") & "')"" ><u>" & rs("ProsjektID") &
"</u></div></td>")
Response.Write ("<td>" & rs("Beskrivelse") & "</td>")
Response.Write ("<td>" & rs("TeknikerID") & "</td>")
Response.Write ("<td>" & rs("Frist") & "</td>")
Response.Write ("<td>" & rs("Prosjekt") & "</td>")
Response.Write ("</tr>")
rs.MoveNext
loop
Response.Write ("</table>")
end if
%>
</form>
</BODY>
</html >
<SCRIPT LANGUAGE=javascript>
<!--
function newWindow(req) {
window.open("rediger.asp?projID='" + req +
"'","Beskrivelse","toolbar=0,location=0,directories=0,status=0,menubar=0,scr
ollbars=0,resizable=1,width=400,height=300")
}
//-->
</SCRIPT>
Message #5 by "Brandy" <brandmo@h...> on Mon, 29 Jan 2001 11:42:10 +0100
|
|
yes Quintis I sorted it out and I had also forgot to open the recordset. I
think I was quite tired after a long week..
By the way I found another method with using the dataset with datagrid to
get me edit the data I want from my database..
Thanks..
Brandy
----- Original Message -----
From: "Quintis Venter" <quintisv@u...>
To: "ASP+" <aspx@p...>
Sent: Monday, January 29, 2001 8:47 AM
Subject: [aspx] RE: Operation is not allowed when the object is closed.
> Move the following lines to the bottom (after the last 'rs' item is
> accessed):
>
> rs.Close
> rs=nothing
> conn.Close
> conn=nothing
>
> Let me know if this helps..
>
> Regards
> Quintis
>
> -----Original Message-----
> From: Brandy [mailto:brandmo@h...]
> Sent: 26 January 2001 03:41
> To: ASP+
> Subject: [aspx] Operation is not allowed when the object is closed.
>
>
> I want to create a table where I get a view of my data for editing, the
only
> method I have found to do this with is with recordset, but its not quite
> working completely..
>
> I get an error :
> Operation is not allowed when the object is closed.
>
> Anyone who is able to see what is worng in my code or if I could have done
> this on a easier way with for instance dataset??
>
> Brandy
>
> Ps : have pasted the code under..
>
> <%@ Import Namespace="System.Data" %>
> <%@ Import Namespace="System.Data.SQL" %>
> <%@ Language=VBScript %>
> <HTML>
> <HEAD>
> <META NAME="GENERATOR" Content="Microsoft FrontPage 4.0">
> </HEAD>
> <script language=VB id=Script1 runat="server">
>
> Sub Page_Load(Src As Object, E As EventArgs)
>
> dim strProsjektID, strBeskrivelse,strTeknikerID,strFrist ,strProsjekt
> strProsjektID=Request.Form("cboProsjektID")
>
>
>
> conn = Server.CreateObject("ADODB.Connection")
> rs = Server.CreateObject("ADODB.Recordset")
> connString = ("provider=SQLOLEDB;data
> source=knutepunktet;uid=sa;pwd=;database=sak")
> Conn.ConnectionString = connString
> conn.Open (, , , adAsyncConnect)
>
> rs.Close
> rs=nothing
> conn.Close
> conn=nothing
>
>
> end sub
>
> </SCRIPT>
>
> <BODY>
> <FORM id=Form1 action=result.aspx method=post runat="server">
> <%
> rs = Server.CreateObject("ADODB.Recordset")
>
> if rs.EOF then
> Response.Write ("Ingen records.")
> else
>
> Response.Write ("<table border=""2"" width=""100%"">")
> Response.Write ("<tr><th align=""left"" width=""40%"">ProsjektID </th>")
> Response.Write ("<th align=""left"" width=""15%"">Beskrivelse </th>")
> Response.Write ("<th align=""left"" width=""20%"">TeknikerID </th>")
> Response.Write ("<th align=""left"" width=""15%"">Frist </th>")
> Response.Write ("<th align=""left"" width=""5%"">Prosjekt </th>")
> Response.Write ("</tr>")
> do until rs.eof
> Response.Write ("<td><div style=""cursor:hand;Color:blue""
> onclick=""newWindow('" & rs("ProsjektID") & "')"" ><u>" & rs("ProsjektID")
&
> "</u></div></td>")
> Response.Write ("<td>" & rs("Beskrivelse") & "</td>")
> Response.Write ("<td>" & rs("TeknikerID") & "</td>")
> Response.Write ("<td>" & rs("Frist") & "</td>")
> Response.Write ("<td>" & rs("Prosjekt") & "</td>")
> Response.Write ("</tr>")
> rs.MoveNext
> loop
> Response.Write ("</table>")
>
> end if
> %>
> </form>
>
>
> </BODY>
> </html >
>
>
>
> <SCRIPT LANGUAGE=javascript>
> <!--
>
> function newWindow(req) {
>
> window.open("rediger.asp?projID='" + req +
>
"'","Beskrivelse","toolbar=0,location=0,directories=0,status=0,menubar=0,scr
> ollbars=0,resizable=1,width=400,height=300")
>
>
> }
> //-->
> </SCRIPT>
>
>
|
|
 |