ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 20th, 2004, 07:58 AM
Captain Morgan Captain Morgan is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 2 Captain Morgan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy ASP guestbook help

hey guys, doing my first guestbook with asp and its giving me some trouble. i was following an online tutorial but so far im stuck with the error: "Operation is not allowed when the object is open." any help would be great. heres the code that I have.

<%
Dim adoCon 'Holds the Database Connection Object
Dim rsAddComments 'Holds the recordset for the new record to be added
Dim strSQL 'Holds the SQL query to query the database
Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("guestbook.mdb")
adoCon.Open "DSN=guestbook"
Set rsAddComments = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT tblComments.Name, tblComments.Comments FROM tblComments;"
rsAddComments.CursorType = 2
rsAddComments.LockType = 3
rsAddComments.Open strSQL, adoCon
rsAddComments.AddNew
rsAddComments.Fields("Name") = Request.Form("name")
rsAddComments.Fields("Comments") = Request.Form("comments")
rsAddComments.Update
rsAddComments.Close
Set rsAddComments = Nothing
Set adoCon = Nothing
Response.Redirect "guestbook.asp"
%>

Reply With Quote
  #2  
Old July 20th, 2004, 08:06 AM
Captain Morgan Captain Morgan is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 2 Captain Morgan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
oh, it said the error is on line 10

Reply With Quote
  #3  
Old July 20th, 2004, 01:48 PM
EiSa EiSa is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: Norway
Posts: 184 EiSa User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 22 m 24 sec
Reputation Power: 16
Where is this tutorial found? It's waste of resources to create a recordset when inserting new records, don't do that.

Anyway, another example thrown together:
Code:
set conn = server.createobject("adodb.connection")
DSNtemp="DRIVER={Microsoft Access Driver (*.mdb)}; "
DSNtemp=dsntemp & "DBQ=" & server.mappath("guestbook.mdb")
conn.Open DSNtemp

SQLstmt = "INSERT INTO tblComments (Name,Comments)"
SQLstmt = SQLstmt & " VALUES ('" & Request.Form("name")& "','" & Request.Form("comments") & "')"
conn.execute(SQLstmt)

conn.close
set conn = nothing
set sqlstmt = nothing 

By the way, if I don't remember wrong, Name is a reserved word and should not be used. It's often better to not use Microsoft Access Driver also. See http://www.connectionstrings.com/ for other options.
__________________
Strictly CSS | Poker Cognac XO

Reply With Quote
  #4  
Old December 21st, 2009, 09:40 AM
abigree abigree is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2009
Posts: 3 abigree User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 35 sec
Reputation Power: 0
hmm. attractive :)

hm.. cognitively post

Reply With Quote
  #5  
Old March 18th, 2010, 02:37 PM
Slai10 Slai10 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2010
Posts: 1 Slai10 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 18 m 2 sec
Reputation Power: 0
2010 Business 2010

Your next answer to forex discusion..

How to become to rich ? AUTOMATED FOREX SYSTEM

hotmail.zulutrade.com

YOU OPEN ACCOUNT AND ADD A SIGNAL PROVIDER
from PERFORMANCE...

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingASP Development > ASP guestbook help


Developer Shed Advertisers and Affiliates


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 | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap