Print Page | Close Window

I can’t believe I can’t do rs.AddNew

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=8435
Printed Date: 01 April 2026 at 7:19am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: I can’t believe I can’t do rs.AddNew
Posted By: Shimpi06
Subject: I can’t believe I can’t do rs.AddNew
Date Posted: 30 December 2003 at 2:33pm

ok, I'm trying to do a recordset.AddNew much like Web Wiz's guestbook example. However, where guestbook adds two fields, I am trying to add 5 fields. However, I am trying to add the records to a new table which I have added to the pre-existing news.mdb from Web Wiz's News script.

What I see happening is --it adds a new record to the table, but the data from the form is not being written to the table.

rsAddAuthor.Fields("First_name") = Request.Form("firstname")
rsAddAuthor.Fields("Last_name") = Request.Form("lastname")
rsAddAuthor.Fields("Email") = Request.Form("email")
rsAddAuthor.Fields("Username") = Request.Form("username")
rsAddAuthor.Fields("Password") = Request.Form("password")

The script ends successfully with no errors.

I hope someone can help me because I will puke if I have to resort to SQLINSERT's.

-Chuck




Replies:
Posted By: KCWebMonkey
Date Posted: 30 December 2003 at 3:30pm

what is the rest of your code? does it look something like the code below?

sqlQuery = "SELECT tblMyTable.* FROM tblMyTable"
rsAddAuthor.CursorType = 2
rsAddAuthor.LockType = 3
rsAddAuthor.Open sqlQuery, myConn
rsAddAuthor.AddNew
rsAddAuthor.Fields("First_name") = Request.Form("firstname")
rsAddAuthor.Fields("Last_name") = Request.Form("lastname")
rsAddAuthor.Fields("Email") = Request.Form("email")
rsAddAuthor.Fields("Username") = Request.Form("username")
rsAddAuthor.Fields("Password") = Request.Form("password")
rsAddAuthor.Update



Posted By: Shimpi06
Date Posted: 30 December 2003 at 4:59pm

KCWebMonkey: It looks precisely as that...

Here...

*****begin paste*****
<% Option Explicit %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<%
dim rsAddAuthor
dim adoCon
dim strSQL


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

'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("news.mdb")

'Intialise the ADO recordset object
Set rsAddAuthor  = Server.CreateObject("ADODB.Recordset")
 

'Initalise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT tblAuthor.* From tblAuthor;"

'Set the cursor type property of the record set to Dynamic so we can navigate through the record set
rsAddAuthor.CursorType = 2

'Set the Lock Type for the records so that the record set is only locked when it is updated
rsAddAuthor.LockType = 3
 
'Query the database
rsAddAuthor.Open strSQL, adoCon

'Add a new record to the recordset if it's a new News Item
rsAddAuthor.AddNew

'add new record to the recordset 
rsAddAuthor.Fields("First_name") = Request.Form("firstname")
rsAddAuthor.Fields("Last_name") = Request.Form("lastname")
rsAddAuthor.Fields("Email") = Request.Form("email")
rsAddAuthor.Fields("Username") = Request.Form("username")
rsAddAuthor.Fields("Password") = Request.Form("password")
   
'Update the database with the new user's info
rsAddAuthor.Update

'Reset Server Objects
rsAddAuthor.Close
Set adoCon = Nothing
Set rsAddAuthor = Nothing


response.redirect"author.asp"
%>

*****end paste*****



Posted By: KCWebMonkey
Date Posted: 30 December 2003 at 10:39pm

have you verified that the info is being transferred from the form to the script? try something like:

Response.Write("firstname")



Posted By: Shimpi06
Date Posted: 31 December 2003 at 9:55am
(bangs head against surface of desk)
My forms were written wrong...
They were written as

<input type="username" maxlength="12">
...I didn't have a name=" " in the input nor did I specify type="text"

Grrrrr....

All day I was looking at the scripts and I never thought of looking at the form.



Posted By: KCWebMonkey
Date Posted: 31 December 2003 at 11:26am
LOL, if you look at this thread http://forums.webwiz.net/forum_posts.asp?TID=7959&PN=2 - http://forums.webwiz.net/forum_posts.asp?TID=7959&a mp;PN=2  you will see that i did almost the same thing a couple of weeks ago.



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