SunQuest
           ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old August 6th, 2003, 04:53 AM
carolo carolo is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 1 carolo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
problem with recordset object

Hello! I've got a problem with recordset object.
Error type
ADODB.Recordset (0x800A0E78)
operation is not allowed if object is closed. Error is in line 31 .
I attach you the code in orden to have a look!!!!
The problem happends when I use an INSERT statemen; if I use a SELECT statement nothing happends.
Which could be the error and solution to the problem?
Thanks!!!!!!!!
Attached Files
File Type: txt objeto_recordset.txt (1.6 KB, 281 views)

Reply With Quote
  #2  
Old August 6th, 2003, 06:03 AM
Spudhead Spudhead is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 146 Spudhead User rank is Corporal (100 - 500 Reputation Level)Spudhead User rank is Corporal (100 - 500 Reputation Level)Spudhead User rank is Corporal (100 - 500 Reputation Level)Spudhead User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 19 h 19 m 14 sec
Reputation Power: 7
Why are you using a recordset to do an insert? Just make the connection execute it.

Reply With Quote
  #3  
Old August 6th, 2003, 06:09 AM
Vlince Vlince is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Canada, Quebec, Montreal
Posts: 410 Vlince User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Ok I've downloaded your file and paste the code into a tmp.asp page of mine. I took away the comments you had made and this is the final result.

NOTE: Like I said, I haven't change anything yet I've simply took away the comments.

-----------------------------------------------------------------------------------
<HTML>
<HEAD>
</HEAD>
<BODY bgcolor=FFD038>

<H1 align="center"> ALTA DE ALUMNOS </H1>

<%
dim Obj_Conn
dim Obj_Rs
dim SQL

Set Obj_Conn=Server.CreateObject("ADODB.Connection")
Set Obj_Rs=Server.CreateObject ("ADODB.Recordset")

SQL="INSERT persona(nombre) values('gonzalo')"

Obj_Conn.Open("provider=SQLOLEDB.1;database=secretaria;uid=pepe; pwd=pepe")
Obj_Rs.Open SQL,Obj_Conn
%>

<p>Se ha establecido la conexion con la BBDD</p>

<a href="./baja_alumnos.asp">Ver alumnos</a>
<%
Obj_Rs.Close
Obj_Conn.Close
SET Obj_Rs=Nothing
SET Obj_Conn=Nothing
%>
<p>Se ha cerrado la conexion con la BBDD</p>

</BODY>
</HTML>
-----------------------------------------------------------------------------------

Now the first thing that I've notice is WHY are you intermingling your ASP code with the HTML code???

After all, your simply making an INSERT query that's it that's all so why mix it with your HTML???

Why not simply put it at the beginning(top) of your asp page this way you'll clarify your code.

Another thing, I've notice that your INSERT statement is wrong, shouldn't it be INSERT INTO TableName ...

Notice the *INTO*

Now to make this clearer, let's try and keep the ASP code together and the same thing with the HTML. The end result should look something like:


-----------------------------------------------------------------------------------
<%@ Language=VBScript %>

<%
dim Obj_Conn
dim Obj_Rs
dim SQL

Set Obj_Conn=Server.CreateObject("ADODB.Connection")
Set Obj_Rs=Server.CreateObject ("ADODB.Recordset")

SQL="INSERT INTO persona(nombre) values('gonzalo')"

Obj_Conn.Open("provider=SQLOLEDB.1;database=secretaria;uid=pepe; pwd=pepe")
Obj_Rs.Open SQL,Obj_Conn

Obj_Rs.Close
Obj_Conn.Close
SET Obj_Rs=Nothing
SET Obj_Conn=Nothing
%>


<HTML>
<HEAD>
</HEAD>
<BODY bgcolor=FFD038>

<H1 align="center"> ALTA DE ALUMNOS </H1>

<p>Se ha establecido la conexion con la BBDD</p>

<a href="./baja_alumnos.asp">Ver alumnos</a>

<p>Se ha cerrado la conexion con la BBDD</p>

</BODY>
</HTML>
-----------------------------------------------------------------------------------

Notice the INTO keyword that I've added for you.

Another thing...why are you creating a Recordset Object ???
Your query is an INSERT right? INSERT's don't return a recordset, it inserts data in your database that's it that's all so why create the overhead in your code ?

So that's it for your code, but then you say...I want to use a SELECT query!

Well if it is a SELECT Query then the process changes a bit in the sense that yes you'll need a Recordset Object.


Hope this helps!
Sincerely

Vlince

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > problem with recordset object


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway