|
| |
|
|
bango
Posts: 40 Joined: 8/23/2004 Status: offline
|
Operation is not allowed when the object is closed. - 11/12/2004 12:48:42
Operation is not allowed when the object is closed. I am having this problem when performing multiple inserts into different DB's on the same page. The data actually inserts however the web page does not refresh properly. The code is included. <%
'First we create a connection object
Set Conn = Server.CreateObject("ADODB.Connection")
'Next, we open the connection object by calling the connection string
'that FrontPage created and stored in the global.asa file when the "customers"
'connection was created
Conn.Open Application("customers_ConnectionString")
'Then we create a record set object and a SQL statement
Set RS = Conn.Execute ("SELECT * From tbl_Customers WHERE Username = '" & Session("txtfrom") & "'")
'Loop through the database to check for the users information
Do until RS.EOF
Username = RS("Username")
RS.MoveNext
loop
'Close the recordset and database connection
RS.Close
Set RS = nothing
Conn.Close
Set Conn = nothing
'If the username given is not in the database then we don't do anything.
'Otherwise, we create the session objects
IF Username = "" Then %>
<input type="hidden" name="hidden" value="<% = Request.Form("txtFrom") %>" size="20">
<%
'First we create a connection object
Set Conn = Server.CreateObject("ADODB.Connection")
'Next, we open the connection object by calling the connection string
'that FrontPage created and stored in the global.asa file when the "customers"
'connection was created
Conn.Open Application("customers_ConnectionString")
'Then we create a record set object and a SQL statement
Set RS = Conn.Execute ("INSERT INTO tbl_customers (Username,CustomerType,Zip,Phone,UserIPAddress) VALUES ('" & Request.Form("txtFrom") & "','4','" & Request.Form("zipCode") & "','" & Request.Form("areaCode") & "-" & Request.Form("prefix") & "-" & Request.Form("lineNumber") & "','" & Request.ServerVariables("REMOTE_ADDR") & "')")
Do until RS.EOF
RS.MoveNext
loop
'Close the recordset and database connection
RS.Close
Set RS = nothing
Conn.Close
Set Conn = nothing
%>
<% Else
End IF
%>
<%
'First we create a connection object
Set Conn = Server.CreateObject("ADODB.Connection")
'Next, we open the connection object by calling the connection string
'that FrontPage created and stored in the global.asa file when the "customers"
'connection was created
Conn.Open Application("emaildata_ConnectionString")
'Then we create a record set object and a SQL statement
Set RS = Conn.Execute ("INSERT INTO tbl_EmailRecords (Username,EmailZipCode,EmailPhone,ID,TradeIn,Finance,TimeFrame,TradeYear,TradeMake,TradeModel,TradeMileage,EmailType,UserIPAddress) VALUES ('" & Request.Form("txtFrom") & "','" & Request.Form("zipCode") & "','" & Request.Form("areaCode") & "-" & Request.Form("prefix") & "-" & Request.Form("lineNumber") & "','" & Request.Form("ID") & "','" & Request.Form("R1") & "','" & Request.Form("Finance") & "','" & Request.Form("TimeFrame") & "','" & Request.Form("TradeYear") & "','" & Request.Form("TradeMake") & "','" & Request.Form("TradeModel") & "','" & Request.Form("TradeMileage") & "','2','" & Request.ServerVariables("REMOTE_ADDR") & "')")
Do until RS.EOF
RS.MoveNext
loop
'Close the recordset and database connection
RS.Close
Set RS = nothing
Conn.Close
Set Conn = nothing
%>
|
|
|
|
Spooky
Posts: 26606 Joined: 11/11/1998 From: Middle Earth Status: offline
|
RE: Operation is not allowed when the object is closed. - 11/12/2004 13:19:19
try this : <%
'First we create a connection object
Set Conn = Server.CreateObject("ADODB.Connection")
'Next, we open the connection object by calling the connection string
'that FrontPage created and stored in the global.asa file when the "customers"
'connection was created
Conn.Open Application("customers_ConnectionString")
'Then we create a record set object and a SQL statement
Set RS = Conn.Execute ("SELECT Username From tbl_Customers WHERE Username = '" & Session("txtfrom") & "'")
'Loop through the database to check for the users information
Do until RS.EOF
Username = RS(0)
RS.MoveNext
loop
'Close the recordset and database connection
RS.Close
Set RS = nothing
'If the username given is not in the database then we don't do anything.
'Otherwise, we create the session objects
IF Username = "" Then %>
<input type="hidden" name="hidden" value="<% = Request.Form("txtFrom") %>" size="20">
<%
'Then we create a record set object and a SQL statement
Conn.Execute ("INSERT INTO tbl_customers (Username,CustomerType,Zip,Phone,UserIPAddress) VALUES ('" & Request.Form("txtFrom") & "','4','" & Request.Form("zipCode") & "','" & Request.Form("areaCode") & "-" & Request.Form("prefix") & "-" & Request.Form("lineNumber") & "','" & Request.ServerVariables("REMOTE_ADDR") & "')")
End IF
'Then we create a record set object and a SQL statement <-- Should this be above the end if?
Conn.Execute ("INSERT INTO tbl_EmailRecords (Username,EmailZipCode,EmailPhone,ID,TradeIn,Finance,TimeFrame,TradeYear,TradeMake,TradeModel,TradeMileage,EmailType,UserIPAddress) VALUES ('" & Request.Form("txtFrom") & "','" & Request.Form("zipCode") & "','" & Request.Form("areaCode") & "-" & Request.Form("prefix") & "-" & Request.Form("lineNumber") & "','" & Request.Form("ID") & "','" & Request.Form("R1") & "','" & Request.Form("Finance") & "','" & Request.Form("TimeFrame") & "','" & Request.Form("TradeYear") & "','" & Request.Form("TradeMake") & "','" & Request.Form("TradeModel") & "','" & Request.Form("TradeMileage") & "','2','" & Request.ServerVariables("REMOTE_ADDR") & "')")
'Close the database connection
Conn.Close
Set Conn = nothing
%> Note - you should be checking your database input for injected characters
_____________________________
If you arent part of the solution, then there is good money to be made prolonging the problem §þ k¥
|
|
|
|
bango
Posts: 40 Joined: 8/23/2004 Status: offline
|
RE: Operation is not allowed when the object is closed. - 11/12/2004 13:50:42
Spooky, Error: Could not find output table 'tbl_EmailRecords'. I'm assuming this is due to the fact that this table is located in a DB seperate than the customers connection string (tbl_EmailRecords located in Emaildata connection string) which is stripped out of the new code. Any ideas? Much Appreciated
|
|
|
|
bango
Posts: 40 Joined: 8/23/2004 Status: offline
|
RE: Operation is not allowed when the object is closed. - 11/12/2004 14:23:41
Understandable, Your only trying to maintain about 200,000 pages Spooky. Get it together. HA ! Just kidding. Your extremly knowledgable on this and impact alot of individuals. For that I thank you. As for the overall error on this issue. I have resolved it based on your suggestions however I am unclear as to what your changes impacted. Is setting Username = RS(0) the solution and in doing so what does that effectively do ? Thanks Again bando
|
|
|
|
bango
Posts: 40 Joined: 8/23/2004 Status: offline
|
RE: Operation is not allowed when the object is closed. - 11/12/2004 14:50:41
Wonderful, Thanks again for the assistance and explanation.
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
|
|
|