Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    Round Rock, Texas
    Posts
    443
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy How to pass multiple <select> values to database

    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]

    Code:
    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
    Last edited by RadarBob; 08-14-2002 at 04:39 PM.

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    Cincinnati, OH
    Posts
    545
    Thanks
    0
    Thanked 0 Times in 0 Posts
    the one thing I see is that you do not have a rs.update

    Code:
    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

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    Round Rock, Texas
    Posts
    443
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    Cincinnati, OH
    Posts
    545
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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:

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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •