Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - I can’t believe I can’t do rs.AddNew
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

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

 Post Reply Post Reply
Author
Shimpi06 View Drop Down
Groupie
Groupie


Joined: 30 December 2003
Location: United States
Status: Offline
Points: 70
Post Options Post Options   Thanks (0) Thanks(0)   Quote Shimpi06 Quote  Post ReplyReply Direct Link To This Post Topic: I can’t believe I can’t do rs.AddNew
    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

Back to Top
KCWebMonkey View Drop Down
Senior Member
Senior Member
Avatar
Go Chiefs!

Joined: 21 June 2002
Status: Offline
Points: 1319
Post Options Post Options   Thanks (0) Thanks(0)   Quote KCWebMonkey Quote  Post ReplyReply Direct Link To This Post 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



Edited by KCWebMonkey
Back to Top
Shimpi06 View Drop Down
Groupie
Groupie


Joined: 30 December 2003
Location: United States
Status: Offline
Points: 70
Post Options Post Options   Thanks (0) Thanks(0)   Quote Shimpi06 Quote  Post ReplyReply Direct Link To This Post 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*****

Back to Top
KCWebMonkey View Drop Down
Senior Member
Senior Member
Avatar
Go Chiefs!

Joined: 21 June 2002
Status: Offline
Points: 1319
Post Options Post Options   Thanks (0) Thanks(0)   Quote KCWebMonkey Quote  Post ReplyReply Direct Link To This Post 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")

Back to Top
Shimpi06 View Drop Down
Groupie
Groupie


Joined: 30 December 2003
Location: United States
Status: Offline
Points: 70
Post Options Post Options   Thanks (0) Thanks(0)   Quote Shimpi06 Quote  Post ReplyReply Direct Link To This Post 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.

Back to Top
KCWebMonkey View Drop Down
Senior Member
Senior Member
Avatar
Go Chiefs!

Joined: 21 June 2002
Status: Offline
Points: 1319
Post Options Post Options   Thanks (0) Thanks(0)   Quote KCWebMonkey Quote  Post ReplyReply Direct Link To This Post Posted: 31 December 2003 at 11:26am
LOL, if you look at this thread 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.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.