Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Addnew Recordsets


Message #1 by "Brad Libby" <libby_brad@b...> on Tue, 26 Sep 2000 03:38:09 +0100
I am trying to insert data into a table via recordsets. the SQL 7.0 table

has an "id" column that AutoNumbers when a new record is inserted.  he is

the code the session at the top make sure the user is logged in..



<!-- metadata type = "typelib"

				file = "c:\program files\common files\system\ado\msado15.dll" -->

<% if session("sell")<> true then

response.redirect "index.asp"

else%>

<%

username = request.form("username")

title = request.form("title")

category=request.form("category")

description=request.form("description")

quantity=request.form("quantity")

uploadpic=request.form("uploadpic")

itemlocation=request.form("itemlocation")

webpage=request.form("webpage")

duration=request.form("duration")

reserve=request.form("reserve")

minbid=request.form("minbid")

payment=request.form("payment")

finalcost=request.form("finalcost")

shipping=request.form("shipping")

bold=request.form("bold")

highlight=request.form("highlight")

featured=request.form("featured")

catfeatured=request.form("catfeatured")

submitdate = FormatDateTime(Date, 1) 

datenow = FormatDateTime(Date)

enddate = DateAdd("d", duration, datenow)

submittime = FormatDateTime(Now, 3)





dim objrs, strconnect, strcriteria

strconnect = "DRIVER={SQL

Server};SERVER=sqldata;LANGUAGE=us_english;DATABASE=mydata;UID=mydatabase;PWD=mypass"



set objrs = server.createobject("adodb.recordset")

objrs.open "users", strconnect, adopendynamic, adlockoptimistic

objrs.addnew

objrs(seller) = username ('error occurs here)

objrs(title) = title

objrs(category) = category

objrs(description) = description

objrs(quantity) = quantity

objrs(haspic) = uploadpic

objrs(sellerlocation) = itemlocation

objrs(haslink) = webpage

objrs(length) = duration

objrs(reserve) = reserve

objrs(minbid) = minbid

objrs(payment) = payment

objrs(totalprice) = finalcost

objrs(shipping) = shipping

objrs(bold) = bold

objrs(highlight) = highlight

objrs(homefeatured) = featured

objrs(catfeatured) = catfeatured

objrs(submitdate) = submitdate

objrs(enddate) = enddate

objrs(submittime) = submittime

objrs.update



objrs.close

set objrs = nothing

%>







This script returns this error



ADODB.Recordset error '800a0cc1' 



Item cannot be found in the collection corresponding to the requested name

or ordinal.



/sell/postit.asp, line 36 



Again i have checked that all the column names are valid.  I have been

around this stuff a while and have always used the insert method..

recordsets are easier that is why i choose it this time.



Thanks

Brad



Message #2 by "Joe Sabado" <joe.sabado@g...> on Tue, 26 Sep 2000 02:14:42 -0700
objrs(seller)  should be objrs("seller")



do the same for everything else



----- Original Message -----

From: Brad Libby <libby_brad@b...>

To: ASP Databases <asp_databases@p...>

Sent: Monday, September 25, 2000 7:38 PM

Subject: [asp_databases] Addnew Recordsets





> I am trying to insert data into a table via recordsets. the SQL 7.0 table

> has an "id" column that AutoNumbers when a new record is inserted.  he is

> the code the session at the top make sure the user is logged in..

>

> <!-- metadata type = "typelib"

> file = "c:\program files\common files\system\ado\msado15.dll" -->

> <% if session("sell")<> true then

> response.redirect "index.asp"

> else%>

> <%

> username = request.form("username")

> title = request.form("title")

> category=request.form("category")

> description=request.form("description")

> quantity=request.form("quantity")

> uploadpic=request.form("uploadpic")

> itemlocation=request.form("itemlocation")

> webpage=request.form("webpage")

> duration=request.form("duration")

> reserve=request.form("reserve")

> minbid=request.form("minbid")

> payment=request.form("payment")

> finalcost=request.form("finalcost")

> shipping=request.form("shipping")

> bold=request.form("bold")

> highlight=request.form("highlight")

> featured=request.form("featured")

> catfeatured=request.form("catfeatured")

> submitdate = FormatDateTime(Date, 1)

> datenow = FormatDateTime(Date)

> enddate = DateAdd("d", duration, datenow)

> submittime = FormatDateTime(Now, 3)

>

>

> dim objrs, strconnect, strcriteria

> strconnect = "DRIVER={SQL

>

Server};SERVER=sqldata;LANGUAGE=us_english;DATABASE=mydata;UID=mydatabase;PW

D=mypass"

>

> set objrs = server.createobject("adodb.recordset")

> objrs.open "users", strconnect, adopendynamic, adlockoptimistic

> objrs.addnew

> objrs(seller) = username ('error occurs here)

> objrs(title) = title

> objrs(category) = category

> objrs(description) = description

> objrs(quantity) = quantity

> objrs(haspic) = uploadpic

> objrs(sellerlocation) = itemlocation

> objrs(haslink) = webpage

> objrs(length) = duration

> objrs(reserve) = reserve

> objrs(minbid) = minbid

> objrs(payment) = payment

> objrs(totalprice) = finalcost

> objrs(shipping) = shipping

> objrs(bold) = bold

> objrs(highlight) = highlight

> objrs(homefeatured) = featured

> objrs(catfeatured) = catfeatured

> objrs(submitdate) = submitdate

> objrs(enddate) = enddate

> objrs(submittime) = submittime

> objrs.update

>

> objrs.close

> set objrs = nothing

> %>

>

>

>

> This script returns this error

>

> ADODB.Recordset error '800a0cc1'

>

> Item cannot be found in the collection corresponding to the requested name

> or ordinal.

>

> /sell/postit.asp, line 36

>

> Again i have checked that all the column names are valid.  I have been

> around this stuff a while and have always used the insert method..

> recordsets are easier that is why i choose it this time.

>

> Thanks

> Brad

>

>

Message #3 by Imar Spaanjaars <Imar@S...> on Tue, 26 Sep 2000 11:15:14 +0200
As fas as I can see (but I could be wrong), you need to enclose your RS 

fields in quotes



Unless there is other code you didn't post, lines like this:



objrs(title) = title



will in fact translate to:



objrs(Request.form("title")) = title , or at least to the value of 

Request.form("title")



Try this:



objrs("title") = title



HtH



Imar







At 03:38 AM 9/26/2000 +0100, you wrote:

>I am trying to insert data into a table via recordsets. the SQL 7.0 table

>has an "id" column that AutoNumbers when a new record is inserted.  he is

>the code the session at the top make sure the user is logged in..

>

><!-- metadata type = "typelib"

>                                 file = "c:\program files\common 

> files\system\ado\msado15.dll" -->

><% if session("sell")<> true then

>response.redirect "index.asp"

>else%>

><%

>username = request.form("username")

>title = request.form("title")

>category=request.form("category")

>description=request.form("description")

>quantity=request.form("quantity")

>uploadpic=request.form("uploadpic")

>itemlocation=request.form("itemlocation")

>webpage=request.form("webpage")

>duration=request.form("duration")

>reserve=request.form("reserve")

>minbid=request.form("minbid")



>payment=request.form("payment")

>finalcost=request.form("finalcost")

>shipping=request.form("shipping")

>bold=request.form("bold")

>highlight=request.form("highlight")

>featured=request.form("featured")

>catfeatured=request.form("catfeatured")

>submitdate = FormatDateTime(Date, 1)

>datenow = FormatDateTime(Date)

>enddate = DateAdd("d", duration, datenow)

>submittime = FormatDateTime(Now, 3)

>

>

>dim objrs, strconnect, strcriteria

>strconnect = "DRIVER={SQL

>Server};SERVER=sqldata;LANGUAGE=us_english;DATABASE=mydata;UID=mydatabase;P 

>WD=mypass"

>

>set objrs = server.createobject("adodb.recordset")

>objrs.open "users", strconnect, adopendynamic, adlockoptimistic

>objrs.addnew

>objrs(seller) = username ('error occurs here)

>objrs(title) = title

>objrs(category) = category

>objrs(description) = description

>objrs(quantity) = quantity

>objrs(haspic) = uploadpic

>objrs(sellerlocation) = itemlocation

>objrs(haslink) = webpage

>objrs(length) = duration

>objrs(reserve) = reserve

>objrs(minbid) = minbid

>objrs(payment) = payment

>objrs(totalprice) = finalcost

>objrs(shipping) = shipping

>objrs(bold) = bold

>objrs(highlight) = highlight

>objrs(homefeatured) = featured

>objrs(catfeatured) = catfeatured

>objrs(submitdate) = submitdate

>objrs(enddate) = enddate

>objrs(submittime) = submittime

>objrs.update

>

>objrs.close

>set objrs = nothing

>%>

>

>

>

>This script returns this error

>

>ADODB.Recordset error '800a0cc1'

>

>Item cannot be found in the collection corresponding to the requested name

>or ordinal.

>

>/sell/postit.asp, line 36

>

>Again i have checked that all the column names are valid.  I have been

>around this stuff a while and have always used the insert method..

>recordsets are easier that is why i choose it this time.

>

>Thanks

>Brad

>

>

Message #4 by "Ajax" <ajax@i...> on Tue, 19 Sep 2000 22:53:48 +0530
Brad,

Perhaps u missed this :



objrs("seller") = username  'include the fieldname - seller in double

quotes

			' where "SELLER" is a valid field in table "USERS"





AJAX



----------------------------------------------

If it ain't what it looks like, it ain't worth it

---WYSIWYG Mantra

--------------------------------------------



-----Original Message-----

From: Brad Libby [mailto:libby_brad@b...]

Sent: Tuesday, September 26, 2000 8:08 AM

To: ASP Databases

Subject: [asp_databases] Addnew Recordsets





I am trying to insert data into a table via recordsets. the SQL 7.0 table

has an "id" column that AutoNumbers when a new record is inserted.  he is

the code the session at the top make sure the user is logged in..



<!-- metadata type = "typelib"

				file = "c:\program files\common files\system\ado\msado15.dll" -->

<% if session("sell")<> true then

response.redirect "index.asp"

else%>

<%

username = request.form("username")

title = request.form("title")

category=request.form("category")

description=request.form("description")

quantity=request.form("quantity")

uploadpic=request.form("uploadpic")

itemlocation=request.form("itemlocation")

webpage=request.form("webpage")

duration=request.form("duration")

reserve=request.form("reserve")

minbid=request.form("minbid")

payment=request.form("payment")

finalcost=request.form("finalcost")

shipping=request.form("shipping")

bold=request.form("bold")

highlight=request.form("highlight")

featured=request.form("featured")

catfeatured=request.form("catfeatured")

submitdate = FormatDateTime(Date, 1)

datenow = FormatDateTime(Date)

enddate = DateAdd("d", duration, datenow)

submittime = FormatDateTime(Now, 3)





dim objrs, strconnect, strcriteria

strconnect = "DRIVER={SQL

Server};SERVER=sqldata;LANGUAGE=us_english;DATABASE=mydata;UID=mydatabase;PW

D=mypass"



set objrs = server.createobject("adodb.recordset")

objrs.open "users", strconnect, adopendynamic, adlockoptimistic

objrs.addnew

objrs(seller) = username ('error occurs here)

objrs(title) = title

objrs(category) = category

objrs(description) = description

objrs(quantity) = quantity

objrs(haspic) = uploadpic

objrs(sellerlocation) = itemlocation

objrs(haslink) = webpage

objrs(length) = duration

objrs(reserve) = reserve

objrs(minbid) = minbid

objrs(payment) = payment

objrs(totalprice) = finalcost

objrs(shipping) = shipping

objrs(bold) = bold

objrs(highlight) = highlight

objrs(homefeatured) = featured

objrs(catfeatured) = catfeatured

objrs(submitdate) = submitdate

objrs(enddate) = enddate

objrs(submittime) = submittime

objrs.update



objrs.close

set objrs = nothing

%>







This script returns this error



ADODB.Recordset error '800a0cc1'



Item cannot be found in the collection corresponding to the requested name

or ordinal.



/sell/postit.asp, line 36



Again i have checked that all the column names are valid.  I have been

around this stuff a while and have always used the insert method..

recordsets are easier that is why i choose it this time.



Thanks

Brad




  Return to Index