Print Page | Close Window

what is wrong with this script

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=9413
Printed Date: 31 March 2026 at 11:25pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: what is wrong with this script
Posted By: shiranve
Subject: what is wrong with this script
Date Posted: 31 January 2004 at 4:33am

Can you please tell me what is wrong with this script why it is not adding recoreds to the DB?

<%
'Dimension variables
Dim adoCon         'Holds the Database Connection Object
Dim rswedding   'Holds the recordset for the records in the database
Dim strSQL          'Holds the SQL query to query the database
Dim strDbPathAndName  'Holds the path and name of the database
'Create an ADO connection object
Set adoCon = Server.CreateObject("ADODB.Connection")

strDbPathAndName ="C:\Inetpub\DB\wedding.mdb"
'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & strDbPathAndName

'Create an ADO recordset object
Set rswedding = Server.CreateObject("ADODB.Recordset")
'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT gues.surename, gues.name1, gues.name2, gues.childname, gues.hophone, gues.workphone, gues.mobphone, gues.email, gues.guestnum, gues.checkbox, gues.text FROM gues;"

'Set the cursor type we are using so we can navigate through the recordset
rswedding.CursorType = 2

'Set the lock type so that the record is locked by ADO when it is updated
rswedding.LockType = 3
'Open the recordset with the SQL query
rswedding.Open strSQL, adoCon

rswedding.AddNew
'Add a new record to the recordset
rswedding.Fields("surename") = Request.Form("surename")
rswedding.Fields("Name1") = Request.Form("name1")
rswedding.Fields("Name2") = Request.Form("name2")
rswedding.Fields("childname") = Request.Form("childname")
rswedding.Fields("hophone") = Request.Form("hophone")
rswedding.Fields("workphone") = Request.Form("workphone")
rswedding.Fields("mobphone") = Request.Form("mobphone")
rswedding.Fields("email") = Request.Form("email")
rswedding.Fields("guestnum") = Request.Form("guestnum")
rswedding.Fields("checkbox") = Request.Form("checkbox")
rswedding.Fields("text") = Request.Form("text")
'Write the updated recordset to the database
rswedding.Update
'Reset server objects
rswedding.Close
Set rswedding = Nothing
'Set adoCon = Nothing
Response.Redirect "register.asp"
%>




Replies:
Posted By: MorningZ
Date Posted: 31 January 2004 at 8:33am

do you get errors?
if so, where do you get the error at?

can't expect to just chuck up 40-or-so lines of code and say "fix it"



-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: shiranve
Date Posted: 31 January 2004 at 8:50am

I know

If I was getting any kind of Error Message I would Have sent it but the problem is that I am not getting any thing it is not updating the DB and not getting to the redirect back!

Do you have any suggestions?



Posted By: Semikolon
Date Posted: 31 January 2004 at 9:20am
check if your database has read and write access..


Posted By: shiranve
Date Posted: 31 January 2004 at 11:59am
 This is the error:

Microsoft VBScript runtime error '800a01a8'

Object required: ''

/add_user.asp, line 15



Posted By: Mart
Date Posted: 31 January 2004 at 12:02pm
Can you post line 15 of add_user.asp (and a few lines above and below)


Posted By: shiranve
Date Posted: 31 January 2004 at 12:15pm

Dim adoCon         'Holds the Database Connection Object
Dim rswedding   'Holds the recordset for the records in the database
Dim strSQL          'Holds the SQL query to query the database
Dim strDbPathAndName  'Holds the path and name of the database

'Create an ADO connection object
Set adoCon = Server.CreateObject("ADODB.Connection")

strDbPathAndName ="C:\Inetpub\DB\wedding.mdb"
'Set an active connection to the Connection object using a DSN-less connection
line 15>>rswedding.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & strDbPathAndName

 

 



Posted By: Mart
Date Posted: 31 January 2004 at 12:26pm
Change

rswedding.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & strDbPathAndName

To

adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & strDbPathAndName


Posted By: shiranve
Date Posted: 31 January 2004 at 1:08pm
Thanks on everything every one here was very much helpfull


Posted By: pmormr
Date Posted: 31 January 2004 at 7:38pm
an easier way that i use to set connection strings is...

dim conn
set conn = Server.CreateObject("ADODB.Connection")
conn.provider = "Microsoft.Jet.OLEDB.4.0"
conn.open "c:\mydatabase.mdb"


this is a little bit less cryptic than connection strings

-------------
Paul A Morgan

http://www.pmorganphoto.com/" rel="nofollow - http://www.pmorganphoto.com/



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net