borderAndreaVB free resources for Visual Basic developersborder

AndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2008 Andrea Tincani
:: Create a Product Selection Form with an Access Database

Author  

David Costelloe

Language  

ASP

Operating Systems  

Windows 95, 98 and NT
INCLUDE (DataStore.inc)
<%
strConn = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("Products.mdb")
%>
HTML (SampleOrder.asp)
<!-- METADATA TYPE="typelib" FILE="C:\program Files\Common Files\system\ado\msado15.dll" -->
<!-- #INCLUDE FILE="DataStore.inc" -->
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>David's Sample ASP</title>
</head>

<body bgColor="#FFFFFF" >
<div align="center">

<table border="0" width="525" bgcolor="#FFFFFF" cellspacing="0" cellpadding="5"
style="border: 8px outset rgb(0,0,0)">
  <tr>
    <td width="515" bgcolor="#0000FF"><form action="GetProd.asp" method="post"
    name="MainForm" align="center">
      <p align="center"><b><span style="background-color: #0000FF"><font color="#FFFFFF">David's
      Sample Product ASP<br>
      </font></span><span style="background-color: #00FFFF"><br>
      </span><span style="background-color: #0000FF"><font color="#00FF00">This
      sample has been tested: </font></span><span style="background-color: #00FFFF"><!--webbot
      bot="HitCounter" u-custom i-digits="0" i-image="2"
      PREVIEW="&lt;strong&gt;[Hit Counter]&lt;/strong&gt;" i-resetvalue="0" startspan --><img src="../_vti_bin/fpcount.exe/?Page=ASP%20Samples/SampleOrder.asp|Image=2" alt="Hit Counter"><!--webbot
      bot="HitCounter" endspan i-checksum="11239" -->
      </span><strong><span style="background-color: #0000FF"> <font color="#00FF00">Times</font></span></strong></b></p>
      <div align="center"><table border="1" width="350" cellpadding="3"
      bgcolor="#800000">
        <tr>
          <td align="left" width="499" bgcolor="#0000FF">
            <p align="center"><select name="TypeSearch" size="1">
<%
sQuote = Chr(34)
Set objConn = Server.CreateObject ("ADODB.Connection")
Set objRec = Server.CreateObject ("ADODB.Recordset")
objConn.Open strConn
MySql = "SELECT  Product_ID FROM Prod"
objRec.Open MySql, objConn
While Not objRec.EOF
sName = objRec("Product_ID")
Response.Write "<OPTION ID=" & sQuote & ObjRec("Product_ID") & sQuote & _
" Value=" & sQuote & sName & sQuote & ">"
Response.Write sName & "</OPTION>"
objRec.MoveNext
Wend
objRec.Close
objConn.Close
Set ObjRec = Nothing
Set ObjConn = Nothing
%>
          </select> <font color="#FFFFFF">Select Product ID</font></p>
          </td>
        </tr>
        <center>

<center>
        <tr>
          <td align="center" width="507" bgcolor="#0000FF"><div align="left"><p align="center"><input type="submit"
          name="B1" value="Select Product"><input type="reset" name="B2" value="Clear"> </td>
        </tr>
      </table>
      </center></div>
    </form>
    </td>
  </tr>
</table>
</center></div>

<p>&nbsp;</p>
</body>
</html>
HTML (GetProd.asp)
<%@ LANGUAGE="VBSCRIPT" %>
<!-- #INCLUDE FILE ="DataStore.inc" -->
<!--
<meta HTTP-EQUIV="REFRESH" CONTENT="600">
Refresh page by seconds
-->
<html>

<head>
<title>Products Sample</title>
</head>

<body>
<%

Dim MySql
Dim OrConn
Dim OrRst
Set OrConn = Server.CreateObject("ADODB.Connection")
OrConn.Open strConn
Set OrRst = Server.CreateObject("ADODB.Recordset")
' Here we get the response from the previous form
Mysql = "SELECT * FROM Prod WHERE Product_ID = '" & Request.Form("TypeSearch") & "'"

OrRst.Open Mysql, OrConn
%>


<!-- Build the table HTML -->
<table border="1" width="100%">
  <tr>
    <td width="50%">
      <p align="center"><b>Product</b></td>
    <td width="50%">
      <p align="center"><b>Price</b></td>
  </tr>
  <tr>
    <td width="50%">
      <p align="center"><input TYPE="text" VALUE="<%=OrRst("Description")%>"SIZE="20" </td>
    <td width="50%">
      <p align="center"><input TYPE="text" VALUE="<%=OrRst("Price")%>"SIZE="20"
      </font></td>
  </tr>
</table>

</body>

<%
OrRst.Close
OrConn.Close
Set OrRst = Nothing
Set OrConn = Nothing
%>
Download
** Click here to download the sample (10 Kb) **
:: Navigation

Home

VB Script and ASP

Previous Tip

Next Tip

:: Search this site
Google
:: Sponsored Links



Partners: Il portale per lui e lei | Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2008 Andrea Tincaniborder