Another Drop List question

Discussion in 'ASP General' started by C White, Jan 19, 2005.

  1. C White

    C White Guest

    I've got another drop list problem

    I am using the following code where users select a name, but it should
    pass a name and email into the table

    <select name="user">
    <option value="<% Response.Write (rsUser("Name")) %>">
    <% Response.Write (rsUser("Name")) %>
    <input type="hidden" name="Email" value="<% Response.Write
    (rsUser("Email")) %>">
    </option>
    </select>
    everything seems to be ok when i test the form as the source it produces
    is this:

    <select name="user">
    <option value="1st guy">
    1st guy
    <input type="hidden" name="Email" value="">
    </option>

    <option value="2nd guy">
    2nd guy
    <input type="hidden" name="Email" value="">
    </option>
    </select>

    so everything seems fine, it is pulling the information from the 1st
    table just fine, but when i submit to add the information to the 2nd
    table it does not add the email value, i get the following error

    Microsoft JET Database Engine (0x80004005)
    Field 'Table.Email' cannot be a zero-length string.

    if i change the email field in the table to allow zero length i don't
    get the error, but the email does not go into the table, just the name
    is added (it's an access 2000 database)

    any ideas what i am doing wrong here?

    thanks
    C White, Jan 19, 2005
    #1
    1. Advertising

  2. C White wrote:
    <snip>> if i change the email field in the table to allow zero length i
    don't
    > get the error, but the email does not go into the table, just the name
    > is added (it's an access 2000 database)
    >
    > any ideas what i am doing wrong here?
    >

    Impossible to say without seeing the code used to add the data to the
    database

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
    Bob Barrows [MVP], Jan 19, 2005
    #2
    1. Advertising

  3. C White

    C White Guest

    Sorry bout that, I wasn't sure if anyone would want it, here it is:

    <%

    'declare your variables
    Dim Name, Email
    Dim sConnString, connection, sSQL

    ' Receiving values from Form, assign the values entered to variables
    Name = Request.Form("Name")
    Email = Request.Form("Email")

    'declare SQL statement that will query the database
    sSQL = "INSERT into users (Name, Email) values ('" & Name & "', '" &
    Email & "')"

    'define the connection string, specify database
    'driver and the location of database
    sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=" & Server.MapPath("User_Info.mdb")


    'create an ADO connection object
    Set connection = Server.CreateObject("ADODB.Connection")

    'Open the connection to the database
    connection.Open(sConnString)

    'execute the SQL
    connection.execute(sSQL)

    response.write "The agent information was successfully submitted."

    ' Done. Close the connection object
    connection.Close
    Set connection = Nothing
    %>

    Bob Barrows [MVP] wrote:

    > C White wrote:
    > <snip>> if i change the email field in the table to allow zero length i
    > don't
    >
    >>get the error, but the email does not go into the table, just the name
    >>is added (it's an access 2000 database)
    >>
    >>any ideas what i am doing wrong here?
    >>

    >
    > Impossible to say without seeing the code used to add the data to the
    > database
    >
    C White, Jan 19, 2005
    #3
  4. C White

    Roland Hall Guest

    "C White" wrote in message news:...
    : I've got another drop list problem
    :
    : I am using the following code where users select a name, but it should
    : pass a name and email into the table
    :
    : <select name="user">
    : <option value="<% Response.Write (rsUser("Name")) %>">
    : <% Response.Write (rsUser("Name")) %>
    : <input type="hidden" name="Email" value="<% Response.Write
    : (rsUser("Email")) %>">
    : </option>
    : </select>
    : everything seems to be ok when i test the form as the source it produces
    : is this:
    :
    : <select name="user">
    : <option value="1st guy">
    : 1st guy
    : <input type="hidden" name="Email" value="">
    : </option>
    :
    : <option value="2nd guy">
    : 2nd guy
    : <input type="hidden" name="Email" value="">
    : </option>
    : </select>
    :
    : so everything seems fine, it is pulling the information from the 1st
    : table just fine, but when i submit to add the information to the 2nd
    : table it does not add the email value, i get the following error
    :
    : Microsoft JET Database Engine (0x80004005)
    : Field 'Table.Email' cannot be a zero-length string.
    :
    : if i change the email field in the table to allow zero length i don't
    : get the error, but the email does not go into the table, just the name
    : is added (it's an access 2000 database)
    :
    : any ideas what i am doing wrong here?

    Two things:

    1. If your database field is set to not allow zero-length strings, then it
    needs data. This is not the code where you insert the data, it is the code
    where you are showing values you have received from the data. Have you
    verified the data is not present in the database? Are you getting an error
    when you insert data or do you have an On Error Resume Next line in your
    insert code?

    2. I have found it is often easier and possibly less of a performance hit if
    you put your HTML in strings and then pass them through a routine to write
    it to the page.

    Ex.

    <%@ Language=VBScript %>
    <%
    ..
    ..
    ..

    sub prt(str)
    Response.Write(str & vbCrLf)
    end sub

    dim s
    s = "<select name=""user"">" & vbCrLf & _
    "<option value=""" & rsUser("Name") & """>" & rsUser("Name") & vbCrLf & _
    "<input type=""hidden"" name=""Email"" value=""" & rsUser("Email") & """>"
    & vbCrLf & _
    "</option>" & vbCrLf & _
    "</select>"

    prt s

    %>

    I like this better because my server is not switching back and forth to read
    ASP code and HTML and for me, it makes it easier to line up my quotes. I
    know that my string needs quotes and if I assign a value to an HTML element
    that I need 3, otherwise, adding quotes for HTML means I need 2. So, single
    around the edges, 2 for all HTML values and 3 if I need to pass a value from
    ASP.

    This:
    & vbCrLf

    ....adds a carriage return, line feed to the HTML output so the code is more
    legible. It has nothing to do with how the code runs.

    & _ could probably be shortened to just _ which is a concatentation
    character so VBScript code can resume on the next line.

    I'm building a string that gets passed once and my parser reads the whole
    page, rather than switching back and forth to read ASP, HTML, ASP, etc. I
    am told this is how the parser works. I could redefine "s" as above, or I
    could even have an array of statements, but it gives me better control over
    the output of my data.

    instead of ...

    <%@ Language=VBScript %>
    <%
    ..
    ..
    ..
    %>
    <select name="user">
    <option value="<% Response.Write (rsUser("Name")) %>">
    <% Response.Write (rsUser("Name")) %>
    <input type="hidden" name="Email" value="<% Response.Write
    (rsUser("Email")) %>">
    </option>
    </select>
    <%
    ....
    %>

    ....at the very least you could replace the Response.Writes with =

    <select name="user">
    <option value="<% = rsUser("Name") %>">
    <% = rsUser("Name") %>
    <input type="hidden" name="Email" value="<% = rsUser("Email") %>">
    </option>
    </select>

    HTH...

    --
    Roland Hall
    /* This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose. */
    Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
    WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
    MSDN Library - http://msdn.microsoft.com/library/default.asp
    Roland Hall, Jan 19, 2005
    #4
  5. C White

    C White Guest

    Roland Hall wrote:

    > "C White" wrote in message news:...
    > : I've got another drop list problem
    > :
    > : I am using the following code where users select a name, but it should
    > : pass a name and email into the table
    > :
    > : <select name="user">
    > : <option value="<% Response.Write (rsUser("Name")) %>">
    > : <% Response.Write (rsUser("Name")) %>
    > : <input type="hidden" name="Email" value="<% Response.Write
    > : (rsUser("Email")) %>">
    > : </option>
    > : </select>
    > : everything seems to be ok when i test the form as the source it produces
    > : is this:
    > :
    > : <select name="user">
    > : <option value="1st guy">
    > : 1st guy
    > : <input type="hidden" name="Email" value="">
    > : </option>
    > :
    > : <option value="2nd guy">
    > : 2nd guy
    > : <input type="hidden" name="Email" value="">
    > : </option>
    > : </select>
    > :
    > : so everything seems fine, it is pulling the information from the 1st
    > : table just fine, but when i submit to add the information to the 2nd
    > : table it does not add the email value, i get the following error
    > :
    > : Microsoft JET Database Engine (0x80004005)
    > : Field 'Table.Email' cannot be a zero-length string.
    > :
    > : if i change the email field in the table to allow zero length i don't
    > : get the error, but the email does not go into the table, just the name
    > : is added (it's an access 2000 database)
    > :
    > : any ideas what i am doing wrong here?
    >
    > Two things:
    >
    > 1. If your database field is set to not allow zero-length strings, then it
    > needs data. This is not the code where you insert the data, it is the code
    > where you are showing values you have received from the data. Have you
    > verified the data is not present in the database? Are you getting an error
    > when you insert data or do you have an On Error Resume Next line in your
    > insert code?
    >
    > 2. I have found it is often easier and possibly less of a performance hit if
    > you put your HTML in strings and then pass them through a routine to write
    > it to the page.
    >
    > Ex.
    >
    > <%@ Language=VBScript %>
    > <%
    > .
    > .
    > .
    >
    > sub prt(str)
    > Response.Write(str & vbCrLf)
    > end sub
    >
    > dim s
    > s = "<select name=""user"">" & vbCrLf & _
    > "<option value=""" & rsUser("Name") & """>" & rsUser("Name") & vbCrLf & _
    > "<input type=""hidden"" name=""Email"" value=""" & rsUser("Email") & """>"
    > & vbCrLf & _
    > "</option>" & vbCrLf & _
    > "</select>"
    >
    > prt s
    >
    > %>
    >
    > I like this better because my server is not switching back and forth to read
    > ASP code and HTML and for me, it makes it easier to line up my quotes. I
    > know that my string needs quotes and if I assign a value to an HTML element
    > that I need 3, otherwise, adding quotes for HTML means I need 2. So, single
    > around the edges, 2 for all HTML values and 3 if I need to pass a value from
    > ASP.
    >
    > This:
    > & vbCrLf
    >
    > ...adds a carriage return, line feed to the HTML output so the code is more
    > legible. It has nothing to do with how the code runs.
    >
    > & _ could probably be shortened to just _ which is a concatentation
    > character so VBScript code can resume on the next line.
    >
    > I'm building a string that gets passed once and my parser reads the whole
    > page, rather than switching back and forth to read ASP, HTML, ASP, etc. I
    > am told this is how the parser works. I could redefine "s" as above, or I
    > could even have an array of statements, but it gives me better control over
    > the output of my data.
    >
    > instead of ...
    >
    > <%@ Language=VBScript %>
    > <%
    > .
    > .
    > .
    > %>
    > <select name="user">
    > <option value="<% Response.Write (rsUser("Name")) %>">
    > <% Response.Write (rsUser("Name")) %>
    > <input type="hidden" name="Email" value="<% Response.Write
    > (rsUser("Email")) %>">
    > </option>
    > </select>
    > <%
    > ...
    > %>
    >
    > ...at the very least you could replace the Response.Writes with =
    >
    > <select name="user">
    > <option value="<% = rsUser("Name") %>">
    > <% = rsUser("Name") %>
    > <input type="hidden" name="Email" value="<% = rsUser("Email") %>">
    > </option>
    > </select>
    >
    > HTH...
    >

    HI

    1. I checked the database, it's not inserting the email value

    2. You've given me a lot of examples and explanations to read, thank you
    very much, these will help and i'll let you know if this helps.
    C White, Jan 19, 2005
    #5
  6. C White wrote:
    > Sorry bout that, I wasn't sure if anyone would want it, here it is:
    >
    > <%
    >
    > 'declare your variables
    > Dim Name, Email
    > Dim sConnString, connection, sSQL
    >
    > ' Receiving values from Form, assign the values entered to variables
    > Name = Request.Form("Name")
    > Email = Request.Form("Email")


    You need validation code here to ensure these variables contain what you
    expect. Use the len() function to verify that they contain data.
    >
    > 'declare SQL statement that will query the database
    > sSQL = "INSERT into users (Name, Email) values ('" & Name & "', '" &
    > Email & "')"
    >


    Since you are having a possible sql problem, you need to use basic debugging
    to make sure the sql statement contains what you expect:

    Response.Write sSQL
    Response.End

    You can comment out the above lines when finished debugging. We need to see
    the resulting statement from the browser window. When using concatenation to
    create a dynamic sql statement, your goal is to create a statement that will
    run as-is in your database's query execution tool (the Access Query Builder)

    > connection.Open(sConnString)


    Parentheses are not needed
    http://blogs.msdn.com/ericlippert/archive/2003/09/15/52996.aspx

    >
    > 'execute the SQL
    > connection.execute(sSQL)


    Tell ADO what the command type is (adCmdText = 1) and that you are not
    expecting any records back so it does not waste time and resources behind
    the scenes creating a recordset to receive the resultset (adExecuteNoRecords
    = 128)

    connection.execute sSQL,,129 '1 + 128 = 129


    Bob Barrows
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
    Bob Barrows [MVP], Jan 19, 2005
    #6
  7. C White

    Roland Hall Guest

    "C White" wrote in message news:...
    : Sorry bout that, I wasn't sure if anyone would want it, here it is:
    :
    : <%
    :
    : 'declare your variables
    : Dim Name, Email
    : Dim sConnString, connection, sSQL
    :
    : ' Receiving values from Form, assign the values entered to variables
    : Name = Request.Form("Name")
    : Email = Request.Form("Email")
    :
    : 'declare SQL statement that will query the database
    : sSQL = "INSERT into users (Name, Email) values ('" & Name & "', '" &
    : Email & "')"
    :
    : 'define the connection string, specify database
    : 'driver and the location of database
    : sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
    : "Data Source=" & Server.MapPath("User_Info.mdb")
    :
    :
    : 'create an ADO connection object
    : Set connection = Server.CreateObject("ADODB.Connection")
    :
    : 'Open the connection to the database
    : connection.Open(sConnString)
    :
    : 'execute the SQL
    : connection.execute(sSQL)
    :
    : response.write "The agent information was successfully submitted."
    :
    : ' Done. Close the connection object
    : connection.Close
    : Set connection = Nothing
    : %>

    Where do you verify that the form fields have values? Is that done on the
    client side?

    --
    Roland Hall
    /* This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose. */
    Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
    WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
    MSDN Library - http://msdn.microsoft.com/library/default.asp
    Roland Hall, Jan 20, 2005
    #7
  8. C White

    C White Guest

    Bob Barrows [MVP] wrote:

    > C White wrote:
    >
    >>Sorry bout that, I wasn't sure if anyone would want it, here it is:
    >>
    >><%
    >>
    >>'declare your variables
    >>Dim Name, Email
    >>Dim sConnString, connection, sSQL
    >>
    >>' Receiving values from Form, assign the values entered to variables
    >>Name = Request.Form("Name")
    >>Email = Request.Form("Email")

    >
    >
    > You need validation code here to ensure these variables contain what you
    > expect. Use the len() function to verify that they contain data.
    >
    >>'declare SQL statement that will query the database
    >>sSQL = "INSERT into users (Name, Email) values ('" & Name & "', '" &
    >>Email & "')"
    >>

    >
    >
    > Since you are having a possible sql problem, you need to use basic debugging
    > to make sure the sql statement contains what you expect:
    >
    > Response.Write sSQL
    > Response.End
    >
    > You can comment out the above lines when finished debugging. We need to see
    > the resulting statement from the browser window. When using concatenation to
    > create a dynamic sql statement, your goal is to create a statement that will
    > run as-is in your database's query execution tool (the Access Query Builder)
    >
    >
    >>connection.Open(sConnString)

    >
    >
    > Parentheses are not needed
    > http://blogs.msdn.com/ericlippert/archive/2003/09/15/52996.aspx
    >
    >
    >>'execute the SQL
    >>connection.execute(sSQL)

    >
    >
    > Tell ADO what the command type is (adCmdText = 1) and that you are not
    > expecting any records back so it does not waste time and resources behind
    > the scenes creating a recordset to receive the resultset (adExecuteNoRecords
    > = 128)
    >
    > connection.execute sSQL,,129 '1 + 128 = 129
    >
    >
    > Bob Barrows


    the debugging code shows me the following, (when i set the database to
    allow zero length)

    INSERT into Users (Name, Email) values ('1st guy', '')

    if i move the hidden email field outside of my select code and just set
    it to

    <input type="hidden" name="TL_Email" value="">

    everything works fine and it inserts the email, so this leeds me to
    beleive that there is indeed somethig wrong with the code I am using to
    create the drop box and that I should look at another way of doing it

    here is the full code i am using to generate the drop list

    <select name="Name">
    <%
    'Dimension variables
    Dim adoConName 'Holds the Database Connection Object
    Dim rsName 'Holds the recordset for the records in the database
    Dim strSQLName 'Holds the SQL query for the database

    'Create an ADO connection object
    Set adoConName = Server.CreateObject("ADODB.Connection")

    'Set an active connection to the Connection object using a DSN-less
    connection
    adoConName.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &
    Server.MapPath("User_Info.mdb")

    'Set an active connection to the Connection object using DSN connection
    'adoCon.Open "DSN=guestbook"

    'Create an ADO recordset object
    Set rsName = Server.CreateObject("ADODB.Recordset")

    'Initialise the strSQL variable with an SQL statement to query the database
    strSQLName = "SELECT * FROM Names ORDER by Name ASC;"

    'Open the recordset with the SQL query
    rsName.Open strSQLName, adoConName

    'Loop through the recordset
    Do While not rsName.EOF
    %>
    <option value="<% Response.Write (rsName("Name")) %>">
    <% Response.Write (rsName("Name")) %>
    </option>
    <input type="hidden" name="Email" value="<% Response.Write
    (rsName("Email")) %>">
    <%
    'Move to the next record in the recordset
    rsName.MoveNext

    Loop

    'Reset server objects
    rsName.Close
    Set rsName = Nothing
    Set adoConName = Nothing
    %>
    </select>

    if anyone has suggestions please submit them, in the meantime i will
    re-evaluate how i am generating the drop box
    C White, Jan 20, 2005
    #8
  9. C White

    C White Guest

    Bob Barrows [MVP] wrote:

    > C White wrote:
    >
    >>Sorry bout that, I wasn't sure if anyone would want it, here it is:
    >>
    >><%
    >>
    >>'declare your variables
    >>Dim Name, Email
    >>Dim sConnString, connection, sSQL
    >>
    >>' Receiving values from Form, assign the values entered to variables
    >>Name = Request.Form("Name")
    >>Email = Request.Form("Email")

    >
    >
    > You need validation code here to ensure these variables contain what you
    > expect. Use the len() function to verify that they contain data.
    >
    >>'declare SQL statement that will query the database
    >>sSQL = "INSERT into users (Name, Email) values ('" & Name & "', '" &
    >>Email & "')"
    >>

    >
    >
    > Since you are having a possible sql problem, you need to use basic debugging
    > to make sure the sql statement contains what you expect:
    >
    > Response.Write sSQL
    > Response.End
    >
    > You can comment out the above lines when finished debugging. We need to see
    > the resulting statement from the browser window. When using concatenation to
    > create a dynamic sql statement, your goal is to create a statement that will
    > run as-is in your database's query execution tool (the Access Query Builder)
    >
    >
    >>connection.Open(sConnString)

    >
    >
    > Parentheses are not needed
    > http://blogs.msdn.com/ericlippert/archive/2003/09/15/52996.aspx
    >
    >
    >>'execute the SQL
    >>connection.execute(sSQL)

    >
    >
    > Tell ADO what the command type is (adCmdText = 1) and that you are not
    > expecting any records back so it does not waste time and resources behind
    > the scenes creating a recordset to receive the resultset (adExecuteNoRecords
    > = 128)
    >
    > connection.execute sSQL,,129 '1 + 128 = 129
    >
    >
    > Bob Barrows

    the debugging code shows me the following, (when i set the database to
    allow zero length)

    INSERT into Users (Name, Email) values ('1st guy', '')

    if i move the hidden email field outside of my select code and just set
    it to

    <input type="hidden" name="TL_Email" value="">

    everything works fine and it inserts the email, so this leeds me to
    beleive that there is indeed somethig wrong with the code I am using to
    create the drop box and that I should look at another way of doing it

    here is the full code i am using to generate the drop list

    <select name="Name">
    <%
    'Dimension variables
    Dim adoConName 'Holds the Database Connection Object
    Dim rsName 'Holds the recordset for the records in the database
    Dim strSQLName 'Holds the SQL query for the database

    'Create an ADO connection object
    Set adoConName = Server.CreateObject("ADODB.Connection")

    'Set an active connection to the Connection object using a DSN-less
    connection
    adoConName.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &
    Server.MapPath("User_Info.mdb")

    'Set an active connection to the Connection object using DSN connection
    'adoCon.Open "DSN=guestbook"

    'Create an ADO recordset object
    Set rsName = Server.CreateObject("ADODB.Recordset")

    'Initialise the strSQL variable with an SQL statement to query the database
    strSQLName = "SELECT * FROM Names ORDER by Name ASC;"

    'Open the recordset with the SQL query
    rsName.Open strSQLName, adoConName

    'Loop through the recordset
    Do While not rsName.EOF
    %>
    <option value="<% Response.Write (rsName("Name")) %>">
    <% Response.Write (rsName("Name")) %>
    </option>
    <input type="hidden" name="Email" value="<% Response.Write
    (rsName("Email")) %>">
    <%
    'Move to the next record in the recordset
    rsName.MoveNext

    Loop

    'Reset server objects
    rsName.Close
    Set rsName = Nothing
    Set adoConName = Nothing
    %>
    </select>

    if anyone has suggestions please submit them, in the meantime i will
    re-evaluate how i am generating the drop box
    C White, Jan 20, 2005
    #9
  10. C White

    Roland Hall Guest

    "C White" wrote in message news:...
    : Bob Barrows [MVP] wrote:
    :
    : > C White wrote:
    : >
    : >>Sorry bout that, I wasn't sure if anyone would want it, here it is:
    : >>
    : >><%
    : >>
    : >>'declare your variables
    : >>Dim Name, Email
    : >>Dim sConnString, connection, sSQL
    : >>
    : >>' Receiving values from Form, assign the values entered to variables
    : >>Name = Request.Form("Name")
    : >>Email = Request.Form("Email")
    : >
    : >
    : > You need validation code here to ensure these variables contain what you
    : > expect. Use the len() function to verify that they contain data.
    : >
    : >>'declare SQL statement that will query the database
    : >>sSQL = "INSERT into users (Name, Email) values ('" & Name & "', '" &
    : >>Email & "')"
    : >>
    : >
    : >
    : > Since you are having a possible sql problem, you need to use basic
    debugging
    : > to make sure the sql statement contains what you expect:
    : >
    : > Response.Write sSQL
    : > Response.End
    : >
    : > You can comment out the above lines when finished debugging. We need to
    see
    : > the resulting statement from the browser window. When using
    concatenation to
    : > create a dynamic sql statement, your goal is to create a statement that
    will
    : > run as-is in your database's query execution tool (the Access Query
    Builder)
    : >
    : >
    : >>connection.Open(sConnString)
    : >
    : >
    : > Parentheses are not needed
    : > http://blogs.msdn.com/ericlippert/archive/2003/09/15/52996.aspx
    : >
    : >
    : >>'execute the SQL
    : >>connection.execute(sSQL)
    : >
    : >
    : > Tell ADO what the command type is (adCmdText = 1) and that you are not
    : > expecting any records back so it does not waste time and resources
    behind
    : > the scenes creating a recordset to receive the resultset
    (adExecuteNoRecords
    : > = 128)
    : >
    : > connection.execute sSQL,,129 '1 + 128 = 129
    : >
    : >
    : > Bob Barrows
    :
    : the debugging code shows me the following, (when i set the database to
    : allow zero length)
    :
    : INSERT into Users (Name, Email) values ('1st guy', '')
    :
    : if i move the hidden email field outside of my select code and just set
    : it to
    :
    : <input type="hidden" name="TL_Email" value="">
    :
    : everything works fine and it inserts the email, so this leeds me to
    : beleive that there is indeed somethig wrong with the code I am using to
    : create the drop box and that I should look at another way of doing it
    :
    : here is the full code i am using to generate the drop list
    :
    : <select name="Name">
    : <%
    : 'Dimension variables
    : Dim adoConName 'Holds the Database Connection Object
    : Dim rsName 'Holds the recordset for the records in the database
    : Dim strSQLName 'Holds the SQL query for the database
    :
    : 'Create an ADO connection object
    : Set adoConName = Server.CreateObject("ADODB.Connection")
    :
    : 'Set an active connection to the Connection object using a DSN-less
    : connection
    : adoConName.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &
    : Server.MapPath("User_Info.mdb")
    :
    : 'Set an active connection to the Connection object using DSN connection
    : 'adoCon.Open "DSN=guestbook"
    :
    : 'Create an ADO recordset object
    : Set rsName = Server.CreateObject("ADODB.Recordset")
    :
    : 'Initialise the strSQL variable with an SQL statement to query the
    database
    : strSQLName = "SELECT * FROM Names ORDER by Name ASC;"
    :
    : 'Open the recordset with the SQL query
    : rsName.Open strSQLName, adoConName
    :
    : 'Loop through the recordset
    : Do While not rsName.EOF
    : %>
    : <option value="<% Response.Write (rsName("Name")) %>">
    : <% Response.Write (rsName("Name")) %>
    : </option>
    : <input type="hidden" name="Email" value="<% Response.Write
    : (rsName("Email")) %>">
    : <%
    : 'Move to the next record in the recordset
    : rsName.MoveNext
    :
    : Loop
    :
    : 'Reset server objects
    : rsName.Close
    : Set rsName = Nothing
    : Set adoConName = Nothing
    : %>
    : </select>
    :
    : if anyone has suggestions please submit them, in the meantime i will
    : re-evaluate how i am generating the drop box

    Why is the hidden field inside the select? Are you associating different
    email addresses with different names? If so, there are probably numerous
    ways you could do that but one would be to have a hidden email list, not
    just a hidden field and when posting your form, the index into the select
    provides the index into your hidden list of email addresses and then
    populates a hidden field in your form, outside of the select before
    submitting. This way when the form is posted, the selected index provides
    the name and the other [hidden or not hidden] element in the form for the
    email address. Otherwise it appears all of your email addresses posted will
    be blank.

    I'm surprised that you do not get an error in your insert if the field is
    set to require data for a record.

    --
    Roland Hall
    /* This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose. */
    Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
    WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
    MSDN Library - http://msdn.microsoft.com/library/default.asp
    Roland Hall, Jan 20, 2005
    #10
  11. C White

    C White Guest

    to answer your question

    i have a table that looks as follows:

    name email
    1st guy
    2nd guy

    i just want the drop list to show

    1st guy
    2nd guy

    but it needs to pass both the name and email into the new table, which
    is why i put the email into a hidden field, i should probably state that
    i am just beginning to learn asp and every now and then i come up with
    problems like this to help myself learn, as for why did i put the email
    into a hidden field in the select form, i don't know any better, i
    thought this would be the best way to to it, but i have learned that it
    is not so i am still looking at different ways to accomplish this

    i thank you for your suggestion as it gives me another idea/way to
    approach this problem, hopefully i'll figure it out sooner than later :)



    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    C White, Jan 20, 2005
    #11
  12. C White

    Roland Hall Guest

    "C White" wrote in message news:%23Q7cQAq$...
    : to answer your question
    :
    : i have a table that looks as follows:
    :
    : name email
    : 1st guy
    : 2nd guy
    :
    : i just want the drop list to show
    :
    : 1st guy
    : 2nd guy
    :
    : but it needs to pass both the name and email into the new table, which
    : is why i put the email into a hidden field, i should probably state that
    : i am just beginning to learn asp and every now and then i come up with
    : problems like this to help myself learn, as for why did i put the email
    : into a hidden field in the select form, i don't know any better, i
    : thought this would be the best way to to it, but i have learned that it
    : is not so i am still looking at different ways to accomplish this

    It's not a problem to have the email address in the hidden field but you
    have the hidden field in the middle of a select. It's not working is it?

    You have this:

    <form...>
    <select ...>
    <option...>
    <option...>
    <input type="hidden"... />
    </select>
    </form>

    I think it needs to be this:

    <form...>
    <select ...>
    <option...>
    <option...>
    </select>
    <select style="display: none" ...>
    <option...>
    <option...>
    </select>
    </form>

    Proof of concept:
    http://kiddanger.com/lab/selecthidden1.asp

    Here is the code for the file it posts to:

    <%@ Language=VBScript %>
    <%
    Option Explicit
    Response.Buffer = True

    dim eName, eMail
    eName = Replace(Request.Form("Name"),"'","''")
    eMail = Replace(Request.Form("Email"),"'","''")

    Response.Write "Name: " & eName & "<br />" & vbCrLf
    Response.Write "Email: " & eMail & vbCrLf
    %>

    HTH...

    --
    Roland Hall
    /* This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose. */
    Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
    WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
    MSDN Library - http://msdn.microsoft.com/library/default.asp
    Roland Hall, Jan 20, 2005
    #12
  13. C White

    C White Guest

    Roland Hall wrote:
    > "C White" wrote in message news:%23Q7cQAq$...
    > : to answer your question
    > :
    > : i have a table that looks as follows:
    > :
    > : name email
    > : 1st guy
    > : 2nd guy
    > :
    > : i just want the drop list to show
    > :
    > : 1st guy
    > : 2nd guy
    > :
    > : but it needs to pass both the name and email into the new table, which
    > : is why i put the email into a hidden field, i should probably state that
    > : i am just beginning to learn asp and every now and then i come up with
    > : problems like this to help myself learn, as for why did i put the email
    > : into a hidden field in the select form, i don't know any better, i
    > : thought this would be the best way to to it, but i have learned that it
    > : is not so i am still looking at different ways to accomplish this
    >
    > It's not a problem to have the email address in the hidden field but you
    > have the hidden field in the middle of a select. It's not working is it?
    >
    > You have this:
    >
    > <form...>
    > <select ...>
    > <option...>
    > <option...>
    > <input type="hidden"... />
    > </select>
    > </form>
    >
    > I think it needs to be this:
    >
    > <form...>
    > <select ...>
    > <option...>
    > <option...>
    > </select>
    > <select style="display: none" ...>
    > <option...>
    > <option...>
    > </select>
    > </form>
    >
    > Proof of concept:
    > http://kiddanger.com/lab/selecthidden1.asp
    >
    > Here is the code for the file it posts to:
    >
    > <%@ Language=VBScript %>
    > <%
    > Option Explicit
    > Response.Buffer = True
    >
    > dim eName, eMail
    > eName = Replace(Request.Form("Name"),"'","''")
    > eMail = Replace(Request.Form("Email"),"'","''")
    >
    > Response.Write "Name: " & eName & "<br />" & vbCrLf
    > Response.Write "Email: " & eMail & vbCrLf
    > %>
    >
    > HTH...
    >


    that's great, how did you find that? I've been searching for some time
    now and i came up with nothing, which is why i had to post to being with
    C White, Jan 20, 2005
    #13
  14. C White

    Roland Hall Guest

    "C White" wrote in message news:...
    : Roland Hall wrote:
    : > "C White" wrote in message
    news:%23Q7cQAq$...
    : > : to answer your question
    : > :
    : > : i have a table that looks as follows:
    : > :
    : > : name email
    : > : 1st guy
    : > : 2nd guy
    : > :
    : > : i just want the drop list to show
    : > :
    : > : 1st guy
    : > : 2nd guy
    : > :
    : > : but it needs to pass both the name and email into the new table, which
    : > : is why i put the email into a hidden field, i should probably state
    that
    : > : i am just beginning to learn asp and every now and then i come up with
    : > : problems like this to help myself learn, as for why did i put the
    email
    : > : into a hidden field in the select form, i don't know any better, i
    : > : thought this would be the best way to to it, but i have learned that
    it
    : > : is not so i am still looking at different ways to accomplish this
    : >
    : > It's not a problem to have the email address in the hidden field but you
    : > have the hidden field in the middle of a select. It's not working is
    it?
    : >
    : > You have this:
    : >
    : > <form...>
    : > <select ...>
    : > <option...>
    : > <option...>
    : > <input type="hidden"... />
    : > </select>
    : > </form>
    : >
    : > I think it needs to be this:
    : >
    : > <form...>
    : > <select ...>
    : > <option...>
    : > <option...>
    : > </select>
    : > <select style="display: none" ...>
    : > <option...>
    : > <option...>
    : > </select>
    : > </form>
    : >
    : > Proof of concept:
    : > http://kiddanger.com/lab/selecthidden1.asp
    : >
    : > Here is the code for the file it posts to:
    : >
    : > <%@ Language=VBScript %>
    : > <%
    : > Option Explicit
    : > Response.Buffer = True
    : >
    : > dim eName, eMail
    : > eName = Replace(Request.Form("Name"),"'","''")
    : > eMail = Replace(Request.Form("Email"),"'","''")
    : >
    : > Response.Write "Name: " & eName & "<br />" & vbCrLf
    : > Response.Write "Email: " & eMail & vbCrLf
    : > %>
    : >
    : > HTH...
    : >
    :
    : that's great, how did you find that? I've been searching for some time
    : now and i came up with nothing, which is why i had to post to being with

    When you spend your time in one area of development, you tend to overlook
    some things you have not worked on in awhile. Had I been working more with
    list boxes, I would have probably noticed it right away. I completely
    overlooked it the first time.

    --
    Roland Hall
    /* This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose. */
    Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
    WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
    MSDN Library - http://msdn.microsoft.com/library/default.asp
    Roland Hall, Jan 20, 2005
    #14
  15. C White

    C White Guest

    It worked!!!!!

    Thanks for the explanations and examples!!!!



    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    C White, Jan 21, 2005
    #15
  16. C White

    Roland Hall Guest

    "C White" wrote in message news:%23yI5F%232$...
    : It worked!!!!!
    :
    : Thanks for the explanations and examples!!!!

    You're welcome. (O:=

    --
    Roland Hall
    /* This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose. */
    Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
    WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
    MSDN Library - http://msdn.microsoft.com/library/default.asp
    Roland Hall, Jan 21, 2005
    #16
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. SirPoonga
    Replies:
    2
    Views:
    738
    Ben Strackany
    Jan 7, 2005
  2. weiwei
    Replies:
    0
    Views:
    996
    weiwei
    Jan 5, 2007
  3. Debajit Adhikary
    Replies:
    17
    Views:
    672
    Debajit Adhikary
    Oct 18, 2007
  4. msimmons
    Replies:
    0
    Views:
    452
    msimmons
    Jul 16, 2009
  5. Replies:
    5
    Views:
    247
Loading...

Share This Page