PDA

View Full Version : How to pass multiple <select> values to database


RadarBob
08-14-2002, 04:36 PM
What's wrong with this code? It just times out. I get no error messages of any kind. I have already verified that "fkeywords" values are in the request.form. "SesspersonID" and "DbID" are VBScript variables created and populated previously.

Here's what I'm trying to do:
[list=1]
Create a new recordset
put the values passed via the request.form into the recordset
display each record in the recordset for debug purposes.
[/list=1]


set rsAllDBKeywords = Server.CreateObject("ADODB.Recordset")
rsDBKeywords.ActiveConnection = objConnection
rsDBKeywords.Source = "exec up_scDBKeywordsAdd 'DbID'"
rsDBKeywords.CursorType = 2 'adOpenDynamic (a dynamic cursor)
rsDBKeywords.CursorLocation = 2 'on the server
rsDBKeywords.LockType = 3
rsDBKeywords.Open

rsDBKeywords.Fields.Append "person_ID", adInteger
rsDBKeywords.Fields.Append "database_ID", adInteger
rdDBKeywords.Fields.Append "keyword", adVarChar, 100

for i=1 to Request.Form("fKeywords").Count
rsDBKeywords.AddNew
rsDBKeywords.Fields("person_ID") = SessPersonID
rsDBKeywords.Fields("database_ID")= DbID
rsDBKeywords.Fields("keyword") = Request.Form("fKeywords")(i)
next


rsDBKeywords.MoveFirst
while not rsDBKeywords.EOF
Response.Write rsDBKeywords.Fields("person_ID") & " "
Response.Write rsDBKeywords.Fields("database_ID") & " "
Response.Write rsDBKeywords.Fields("keyword") & " "
rsDBKeywords.MoveNext
Wend

allida77
08-14-2002, 06:45 PM
the one thing I see is that you do not have a rs.update


for i=1 to Request.Form("fKeywords").Count
rsDBKeywords.AddNew
rsDBKeywords.Fields("person_ID") = SessPersonID
rsDBKeywords.Fields("database_ID")= DbID
rsDBKeywords.Fields("keyword") = Request.Form("fKeywords")(i)
rsDBKeywords.Update
next


Does this work for you in ASP?:
rsDBKeywords.Fields.Append "person_ID", adInteger

RadarBob
08-14-2002, 07:48 PM
Does this work for you in ASP?:

quote:
--------------------------------------------------------------------------------
rsDBKeywords.Fields.Append "person_ID", adInteger
--------------------------------------------------------------------------------


I can't tell. Something's not working. That is the syntax shown on the www.devguru recordset::Fields Collection documentation.

allida77
08-15-2002, 01:54 PM
Since no one else has replied I will take another stab. The only time I have seen "rs.Fields.Append " is when someone is creating a connectionless recordset. I know that you want "null " values in your db but you may want to take another approach. Try the following things:

comment out all your all your append lines and make sure the db is being updated(be sure to add the rs.Udpate). If it is, and I could be wrong(not me!) , then you can not use the append method. Try something like:


If SessPersonID <> "" Then
rsDBKeywords.Fields("person_ID") = SessPersonID
Else
rsDBKeywords.Fields("person_ID") = "null"