Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

USER IMPUT

Status
Not open for further replies.

HerickP

IS-IT--Management
May 10, 2000
68
US
I have an ASP page that queries a database to returns POs issued based on criteria &quot;date()&quot;, so only Entered today will be returned. Here is the SQL part of it:<br><br>&lt;%<br>If IsObject(Session(&quot;ASNDatabase_conn&quot;)) Then<br>&nbsp;&nbsp;&nbsp;&nbsp;Set conn = Session(&quot;ASNDatabase_conn&quot;)<br>Else<br>&nbsp;&nbsp;&nbsp;&nbsp;Set conn = Server.CreateObject(&quot;ADODB.Connection&quot;)<br>&nbsp;&nbsp;&nbsp;&nbsp;conn.open &quot;ASNDatabase&quot;,&quot;&quot;,&quot;&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;Set Session(&quot;ASNDatabase_conn&quot;) = conn<br>End If<br>%&gt;&lt;%<br>If IsObject(Session(&quot;WebReport_For_RCC1_rs&quot;)) Then<br>&nbsp;&nbsp;&nbsp;&nbsp;Set rs = Session(&quot;WebReport_For_RCC1_rs&quot;)<br>Else<br>&nbsp;&nbsp;&nbsp;&nbsp;sql = &quot;SELECT [RCC 1].Vendor, [RCC 1].[ASN Issued Date], [RCC 1].[PO Number], [RCC 1].[Costumer Name], [RCC 1].[Method Used], [RCC 1].BOL&nbsp;&nbsp;FROM [RCC 1]&nbsp;&nbsp;GROUP BY [RCC 1].Vendor, [RCC 1].[ASN Issued Date], [RCC 1].[PO Number], [RCC 1].[Costumer Name], [RCC 1].DateEntered, [RCC 1].Status, [RCC 1].[Method Used], [RCC 1].BOL&nbsp;&nbsp;HAVING ((([RCC 1].DateEntered)=date() ) AND (([RCC 1].Status)='IN TRANSIT'))&nbsp;&nbsp;&nbsp;&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;Set rs = Server.CreateObject(&quot;ADODB.Recordset&quot;)<br>&nbsp;&nbsp;&nbsp;&nbsp;rs.Open sql, conn, 3, 3<br>&nbsp;&nbsp;&nbsp;&nbsp;If rs.eof Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rs.AddNew<br>&nbsp;&nbsp;&nbsp;&nbsp;End If<br>&nbsp;&nbsp;&nbsp;&nbsp;Set Session(&quot;WebReport_For_RCC1_rs&quot;) = rs<br>End If<br>%&gt;<br><br>I am new to ASP, so this maybe really easy for you: How to make this so I can have the user to imput the date, instead of useing &quot;date()&quot;???? Like a textbox in the page where the user will type the date and records for that date will return. I know in access u can just put &quot;[]&quot;&nbsp;&nbsp;in the query design, but how in ASP??????<br><br>Thanks a lot guys!!!
 
Before I answer the question,&nbsp;&nbsp;I'd like to make a few suggestions regarding your coding style.&nbsp;&nbsp;First,&nbsp;&nbsp;its a REALLY bad idea to store objects like ADO connections and recordsets in session objects.&nbsp;&nbsp;Your web application will not scale at all.&nbsp;&nbsp;it's much better to store them in a variable,&nbsp;&nbsp;and create and destroy them on every page.&nbsp;&nbsp;There are many articles and white papers written about this.<br>The site <A HREF=" TARGET="_new"> will help you alot with this and much more.<br><br>Second, theres no need to stack your asp code delimiters as you've done.&nbsp;&nbsp;This will make the ASP processor think it's the end of the ASP code, and it will prepare to process straight HTML, only to discover the very next line is ASP.&nbsp;&nbsp;Just get rid of the %&gt;&lt;% you have in the middle.&nbsp;&nbsp;You can put as much ASP code between delimiters as you like, even if there are multiple functions involved.<br><br>Please don't take these comments as criticisms.&nbsp;&nbsp;I'd just hate to see you start off on the wrong foot.<br><br>Now, to answer your question:<br><br>create a web page that contains a form, with an textbox where the user can enter the date:<br>&lt;HTML&gt;<br>&lt;BODY&gt;<br>&lt;FORM action=&quot;process.asp&quot; method=&quot;POST&quot;&gt;<br>Enter Date Here: &lt;INPUT Type=&quot;TEXT&quot; name=&quot;TheDate&quot;&gt;<br>&lt;INPUT type=&quot;SUBMIT&quot; value=&quot;submit&quot;&gt;<br>&lt;/FORM&gt;<br>&lt;/BODY&gt;<br><br>process.asp would contain the code to do the query and generate the results.&nbsp;&nbsp;&nbsp;To retrieve the value that the user entered on the date page,&nbsp;&nbsp;you would do:<br>MyDate = request.forms(&quot;theDate&quot;)<br><br>then plug the variable MyDate into your SQL statement.<br><br>Of course, this is oversimplified, because you'd probably want to validate that the user entered a valid date, etc. and probably there would be other things on the form as well besides the date.<br><br>&lt;/HTML&gt;<br> <p>nick bulka<br><a href=mailto: > </a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top