1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Retreive data from <select>

Discussion in 'C#' started by birre, Aug 7, 2008.

  1. #1
    Hi,

    On my website, i have the following select:
    
    <select id="MachineType" name="MachineType" >
    <%
    
    If Session("Lan") = "N" Then 
      sqlSup = "SELECT * FROM TMACHINETYPES" 
    Else
      sqlSup = "SELECT * FROM TMACHINETYPES" 
    End If
    
    rsSup.Open sqlSup, DatabaseConnection,adOpenKeyset,adLockOptimistic
    If rsSup.EOF <> true Then
    Do until rsSup.EOF %>
    <option VALUE="<%=rsSup("TM_MACH_N")%>"><%=rsSup("TM_MACH_N")%></option><% 					
    rsSup.MoveNext
    Loop
    
    rsSup.Close
    Set rsSup = nothing
    							
    Else
    %><option SELECTED VALUE><%=sTaskNoMachineTYpe%></option><%
    End If
    %>
    
    </select>	
    
    Code (markup):
    So, it's beïng filled up with data from my database. The <select> is a part of a form, that's beïng submitted and saved into the database in another .asp page (so on submit, the website goes to the page 'Update.asp' to save the form into the database.

    Here's where I encounter the problem:

    
    ...
    'retrieve data from the select'
    neTaskMachineType = Request.Form ("MachineType")
    ...
    'save the machinetype into the database
    rsRe("TR_MACHINETYPE") = neTaskMachineType.Text
    
    Code (markup):
    Saving the text from the <input type="text"...> is no problem, I only encounter the problem on my <select> parts of the form.

    This is the error:

    
    Microsoft VBScript runtime error '800a01a8' 
    
    Object required: 'Grasmaaier ' 
    
    
    Code (markup):
    The 'Grasmaaier' is the selected value from the dropdown, so somehow it receives the data, but can't save it into the database.
    I already tried Cstr(), make another variable, Request.Form.Item (, etc, but nothing seems to work.

    Can someone enlighten me? Thank you!
    SEMrush
     
    birre, Aug 7, 2008 IP
    SEMrush
  2. adsenseblog

    adsenseblog Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    the problem isn't in <select> item. the problem is in your sql syntax.

    i think you wrote char value as int value.
    your sql is: sql="UPDATE TABLE SET TABLE_NAME="&Request.form("MachineType")&" "

    the right syntax below:
    sql="UPDATE TABLE SET TABLE_NAME='"&Request.form("MachineType")&"' "
    use single inverted single commas as ' (i dont know what the word of it:) )
     
    adsenseblog, Aug 8, 2008 IP
  3. birre

    birre Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for answering.
    I don't use SQL syntax. I open the table as a dataset, and replace the items via this:

    rsRe("TR_MACHINETYPE") = neTaskMachineType.Text
    Code (markup):
    and then perform a rsRe.Update.
    I'm doing exactly the same with my <input type="text" ...> items, but they don't give an error (the error is exactly at the point where I'm trying to fill the column TR_MACHINETYPE of my dataset rsRe, not on the specific rsRe.Update
     
    birre, Aug 8, 2008 IP
  4. birre

    birre Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Up

    Nobody? :(
     
    birre, Aug 11, 2008 IP
  5. engager

    engager Peon

    Messages:
    28
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    rsRe("TR_MACHINETYPE") = neTaskMachineType.Text

    this is incorrect. ADORecordset.Values collection is Read-Only. so you can not assign any value.
     
    engager, Aug 14, 2008 IP