Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Need help with a combobox, database and some other stuff.

I have a web page with a combobox on, but I wan't to add items to the dropdown list from a database. How shall I code this?



Thanks in advance, Zand








Comments

  • <%<br>
    set conn = server.createobject("ADODB.connection")

    conn.Open "Your database DSN"

    dim sql

    sql = "Select * from Yourtable"

    set rs = conn.execute(sql)

    %>



    that is your database connection, now to populate your drop down box..



    <%do until rs.eof %>

    <%=rs("name")%>

    <%rs.movenext<br>
    loop %>



    Where is says rs("name") that is the name of whatever field in the database you want info displayed from



    Hope that helps





    : I have a web page with a combobox on, but I wan't to add items to the dropdown list from a database. How shall I code this?

    :

    : Thanks in advance, Zand

    :

    :

    :

    :






  • Lets try that agin



    #%

    set conn = server.createobject("ADODB.connection")

    conn.Open "Your database DSN"

    dim sql

    sql = "Select * from Yourtable"

    set rs = conn.execute(sql)

    %#



    that is your database connection, now to populate your drop down box..



    #%do until rs.eof %#

    #option# #%=rs("name")%# #/option#

    #%rs.movenext

    loop %#



    change the #'s to < and >

    Where is says rs("name") that is the name of whatever field in the database you want info displayed from



    Hope that helps





    : I have a web page with a combobox on, but I wan't to add items to the dropdown list from a database. How shall I code this?

    :

    : Thanks in advance, Zand

    :

    :

    :

    :






  • hai to all,

    i think it would be better to open connection after sql statement.

    i used to do this:



    {

    #%

    dim sql

    sql = "Select * from Yourtable"

    set conn = server.createobject("ADODB.connection")

    conn.Open "Your database DSN"

    set rs = conn.execute(sql)

    %#

    }

    this is my principle: Open lately,Close earlier!!



    : Lets try that agin

    :

    : #%

    : set conn = server.createobject("ADODB.connection")

    : conn.Open "Your database DSN"

    : dim sql

    : sql = "Select * from Yourtable"

    : set rs = conn.execute(sql)

    : %#

    :

    : that is your database connection, now to populate your drop down box..

    :

    : #%do until rs.eof %#

    : #option# #%=rs("name")%# #/option#

    : #%rs.movenext

    : loop %#

    :

    : change the #'s to < and >

    : Where is says rs("name") that is the name of whatever field in the database you want info displayed from

    :

    : Hope that helps

    :

    :

    : : I have a web page with a combobox on, but I wan't to add items to the dropdown list from a database. How shall I code this?

    : :

    : : Thanks in advance, Zand

    : :

    : :

    : :

    : :

    :

    :

    :






Sign In or Register to comment.