Eric

Eric

  • NA
  • 1
  • 0

insert textbox entry into query

Apr 10 2007 6:14 PM

I am new to this a need to update a page that I did not code.  What I need to do is take the value entered into a textbox and add it to a query.  The user would enter somthing like %value%  (% being wildcard) into the text box and then click a search button.  This would then add this value to the query.  I know the sql just do not know how to add to the query or get the value from the textbox.  The db is Oracle.  Hope this makes sense.  Part of the code is below. 

<form action="time_to_project_by_project_number-dynamic.asp" method="POST" name="parmform">
    <table border="1">

	<tr>
            <td>Project Number Search:</td>
            <td>
                <input id="txtSearch" type="text" />
                <input id="btnSearch" type="button" value="Search" />
            </td> 
           
        </tr>
        <tr>
            <td>Select Project Number(s):
            </td>
            <td>

<%
parmid = "P1"
provider = "MSDASQL"
datasource = "dbname"
username = "username"
password = "password"
databasetable = "tablename"
valuedatabasecolumn = "columnname"

strConn = "Provider=" & provider & ";Data Source=" & datasource & ";User ID=" & username & ";password=" & password & ";"

query = "SELECT DISTINCT " & valuedatabasecolumn & "," & valuedatabasecolumn & " || ' - ' || description "
query = query & " FROM " & databasetable
query = query & " where POST_DATE >= to_date('01/01/2007', 'MM/DD/YYYY')"

txtSearch=request.form("txtSearch")

set conn = Server.CreateObject("ADODB.Connection")
conn.Open strconn
set rs = conn.Execute( query )

     Response.Write("<SELECT SIZE=15 NAME=" & chr(34) & parmid  & chr(34) & " MULTIPLE>" & chr(13) )
     rs.movefirst
     do while not rs.EOF
         if rs(0) <> "" then
             Response.Write( "<OPTION VALUE=" & chr(34) & rs(0) & chr(34) & ">" & rs(1) & chr(13) )
         end if
         rs.movenext
     loop
     Response.Write("</SELECT>")
 
rs.close
set rs = nothing
set conn = nothing
%>