sql server 2005 - How to search and display results from an SQL database using HTML & ASP? -
i creating new database web front end end. 1 of key facilities database ability search , bring result(s). have setup database , filled tables information. have created view of info needed (as instructed company work for). have setup page how i'd look, here code:
<!-- #include file="inc.head.asp" --> <html> <head> </head> <body> <h1><i>find user name</i></h1> <div id="displaybox" style="border: 3px solid #9c9595; height: 500px; width: 425px" class="blackbox"> <h2> search user </h2> <form name="enter new model" method="post" action=""> <table> <tr><td><h3>name: </td></h3> <td><input type="text" name="model" size="50"></td></tr> <tr><td><h3>section: </td></h3> <td><input type="text" name="nextupgrade" size="50"></td></tr> <tr><td><h3>directorate: </td></h3> <td><input type="text" name="stock" size="50"></td></tr> </table> <table> <textarea name="userhistory" cols="50" rows="10"></textarea></tr> </table> <input type="submit" name="submit" value="search"> </body> <br> <br> <h3><a href="page.index.asp">return home</a></h3> </div> </body> </html> so want able display results within textarea. used surname search @ moment have other searches do, 1 time have accomplished search can adapt others. help can give me much appreciated.
thanks in advance!
you have figure out things in terms of type of database connection, basics (untested):
<% dim struserhistory: struserhistory = "" dim strmodel : trim(request.form("model")) dim strnextupgrade : trim(request.form("nextupgrade")) dim strstock : trim(request.form("stock")) if strmodel<>"" or strnextupgrade<>"" or strstock<>"" dim strquery: strquery = "select username users model= """ & strmodel & """ or nextupgrade= """ & strnextupgrade & """ or stock= """ & strstock & """ dim objconn: set objconn = server.createobject("adodb.connection") dim dsn: dsn="driver={sql server};server=databaseip;database=databasename;uid=username;pwd=password" objconn.open(dsn) dim objrs: set objrs = objconn.execute(strsql) if objrs.eof struserhistory = "no users found" else while not objrs.eof struserhistory = struserhistory & objrs.fields("username").value & "\n" objrs.movenext() loop end if end if %> put in top of page (or create function out of it) , update html form fields like:
<input type="text" name="model" size="50" value="<%=strmodel%>"> <input type="text" name="nextupgrade" size="50" value="<%=strnextupgrade %>"> <input type="text" name="stock" size="50" value="<%=strstock%>"> <textarea name="userhistory" cols="50" rows="10"><%=struserhistory %></textarea> bit of warning if expose evil net have take care of sql injection , such. nice stackoverflow question this showing kinds of prevention methods.
but, should started.
html sql-server-2005 search asp-classic
No comments:
Post a Comment