Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-07-15 : 08:30:32
|
| Jeff Vojtko writes "How do I go about passing a user input in a HTML file through to an SQL statement in a ASP page? For example the user inputs a certain number. That number is passed through to a ASP page in which a SQL statement is to scan a database table for matches and only return those matches.ASP:<html>@ LANGUAGE="VBSCRIPT" <body>Dim NUMSTRINGNUMSTRING = Request.Form("Number")set conn=Server.CreateObject("ADODB.Connection")conn.Provider="Microsoft.Jet.OLEDB.4.0"conn.Open(Server.Mappath("pilot.mdb"))set rs = Server.CreateObject("ADODB.recordset")Response.Write(NUMSTRING)sql="SELECT OEM_Number, Sparex_Number FROM Interchange WHERE OEM_Number LIKE 'NUMSTRING'"rs.Open sql, conn<CENTER><table border="1" width="90%"><TR>for each x in rs.Fields response.write("<th>" & x.name & "</th>")next</TR>do until rs.EOF <TR> for each x in rs.Fields <td bgcolor="#ccccff">Response.Write(x.value)</TD> next rs.MoveNext </TR>looprs.closeconn.close</TABLE></CENTER></body></html>HTML:<html><body><form method="GET" action="pilot.asp">OEM Number: <input type="text" name="Number"><input type="submit" value="Submit"></form></body></html>" |
|
|
joldham
Wiseass Yak Posting Master
300 Posts |
Posted - 2002-07-15 : 09:40:56
|
| sql="SELECT OEM_Number, Sparex_Number FROM Interchange WHERE OEM_Number LIKE '" & NUMSTRING & "'" Jeremy |
 |
|
|
|
|
|