01 | <%@ Page Language="C#" %> |
02 | <%@ Import Namespace="System" %> |
03 | <%@ Import Namespace="System.Data.OleDb" %> |
05 | < script language = "C#" runat = "server" > |
06 | protected void Select_Click( object sender, EventArgs e ) { |
07 | OleDbConnection dbconn = new OleDbConnection( |
08 | @"Provider=Microsoft.ACE.OleDb.12.0;Data Source=" + |
09 | Server.MapPath( "Access\\Grocery.mdb" ) ); |
13 | sql = "SELECT c.cid, p.name FROM coupons c, coupon_product cp,"; |
14 | sql += " products p WHERE cp.pid = p.pid AND c.cid = cp.cid AND"; |
15 | sql += " c.cid IN ( SELECT DISTINCT c1.cid FROM coupons c1,"; |
16 | sql += " coupon_product cp1, products p1 WHERE p1.name LIKE @pName"; |
17 | sql += " AND p1.pid = cp1.pid AND cp1.cid = c1.cid )"; |
18 | sql += " ORDER BY c.cid"; |
20 | OleDbCommand dbcmd = new OleDbCommand( sql, dbconn ); |
21 | dbcmd.Parameters.AddWithValue( "@pName", "%"+pName.Text+"%" ); |
22 | var dbread = dbcmd.ExecuteReader( ); |
23 | coupons.DataSource = dbread; |
33 | < center >< h3 >Finding Coupons</ h3 ></ center >< hr /> |
35 | < asp:TextBox ID = "pName" runat = "server" /> |
36 | < asp:Button ID = "Select" runat = "server" Text = "Find coupons" |
37 | OnClick = "Select_Click" /> |
38 | < asp:Repeater id = "coupons" runat = "server" > |
45 | < td ><%#DataBinder.Eval(Container.DataItem,"cid")%></ td > |
47 | < td ><%#DataBinder.Eval(Container.DataItem,"name")%></ td > |
|
|
|