Forums

ASP

This topic is locked

Updating db field dynamically with posted form

Posted 17 Jan 2004 11:43:26
1
has voted
17 Jan 2004 11:43:26 Mike Mr. posted:
I don't understand why i can't get this to work. I have two pages. On one page i have a text box and three radio buttons with a form and submit button to post to the next page. On that next page i have my connection and recordset to the db. The db has three fields in the recordset. What i want to do is when the user types in text in the text box and selects one of the radios, the next page will update the db with the text in whichever of the three fields the user selects with the radio buttons. If i hard code the recordset and field name, it works fine, but when i try to take out the field name and put a string in it, i get this error:

ADODB.Recordset error '800a0cc1'

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

Here is what i am doing (the db table is text and the fields are text1, text2, and text3) the radio on the first page name is radiobutton and the values are 1, 2, and 3.

Dim text
Dim dbFieldNum
text = request.form("textbox1"
dbFieldNum = request.form("radiobutton"

rsText("dbFieldNum" = text
rsText.Update

this does not work. but if instead of rsText("StringName" = String like i am doing above, if i do rsText("dbFieldName" = String everything works. Does anybody have any ideas??? Need to dynamically choose which field in db to update using the radio buttons.

Thanks!!!!!!!!!!!

Replies

Replied 18 Jan 2004 17:21:23
18 Jan 2004 17:21:23 Phil Shevlin replied:
rsText("dbFieldNum" is looking for a column with the literal name "dbFieldNum"

I've never done this, but off the cuff, I'd say...

try rsText(dbFieldNum)

Reply to this topic