M
Murph
Hi,
I'm new to ASP.NET and have a problem which i'm hoping will be easy to
answer... i have only used VB, HTML and Flash up until now!
I am designing an ASP page which uses OleDb to retrieve data from an
access database and show it on screen... however, i want the viewer
to be able to select an item from a dropdown menu which relates to
one of the fields and have only that information shown... how do i
declare the variable?
Here is my code:
<%@ Import
Namespace="System.Data.OleDb" %>
<script runat="server">
sub Page_Load
dim dbconn,sql,dbcomm,dbread
dbconn=New
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data
source=" &
server.mappath("gigs.mdb"))
dbconn.Open()
sql="SELECT * FROM gigs"
dbcomm=New OleDbCommand(sql,dbconn)
dbread=dbcomm.ExecuteReader()
gigs.DataSource=dbread
gigs.DataBind()
dbread.Close()
dbconn.Close()
end sub
sub getvenue_click (Sender As Object, E As EventArgs)
dim dbconn,sql,dbcomm,dbread
dim myselection
dbconn=New
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data
source=" &
server.mappath("gigs.mdb"))
dbconn.Open()
sql="SELECT * FROM gigs where venue = ???"
dbcomm=New OleDbCommand(sql,dbconn)
dbread=dbcomm.ExecuteReader()
gigs.DataSource=dbread
gigs.DataBind()
dbread.Close()
dbconn.Close()
end sub
</script>
<html>
<body>
<select id="MyDDL" runat="server">
<option>The Brickyard</option>
<option>Whitehaven Civic Hall</option>
<option>Kendal Rugby Club</option>
</select>
<br><br>
<input type="button"
OnServerClick="getvenue_click" value="Show
Results" runat="server">
<br><br>
<form runat="server">
<asp:Repeater id="gigs" runat="server">
<HeaderTemplate>
<!--<table width="100%">
<tr bgcolor="#AA0000">
<th><font face="tahoma" size=2
color="#FFFFFF">Date</th>
<th><font face="tahoma" size=2
color="#FFFFFF">Line-Up</th>
<th><font face="tahoma" size=2
color="#FFFFFF">Venue</th>
<th><font face="tahoma" size=2
color="#FFFFFF">Contact</th>
</tr>-->
</HeaderTemplate>
<ItemTemplate>
<table width="100%">
<tr bgcolor="#FFFFFF">
<td width="25%"><font face="tahoma"
color="#AA0000"
size=2><b><%#Container.DataItem("date")%></b><br><font
size=1><%#Container.DataItem("doorinfo")%></td>
<td width="25%"><font face="tahoma"
color="#AA0000"
size=2><b><%#Container.DataItem("promoter")%></b><br><%#Container.DataItem("band1")%><br><%#Container.DataItem("band2")%><br><%#Container.DataItem("band3")%><br><%#Container.DataItem("band4")%>
</td>
<td width="25%"><font face="tahoma"
color="#AA0000"
size=2><%#Container.DataItem("venue")%><br><font
size=1><%#Container.DataItem("venueadd")%>
</td>
<td width="25%"><font face="tahoma"
color="#AA0000"
size=2><%#Container.DataItem("contact")%>
</td>
</tr>
</table>
<hr color="#E9BEBE">
</ItemTemplate>
<AlternatingItemTemplate>
<table width="100%">
<tr bgcolor="#FFFFFF">
<td width="25%"><font face="tahoma"
size=2><b><%#Container.DataItem("date")%></b><br><font
size=1><%#Container.DataItem("doorinfo")%></td>
<td width="25%"><font face="tahoma"
size=2><b><%#Container.DataItem("promoter")%></b><br><%#Container.DataItem("band1")%><br><%#Container.DataItem("band2")%><br><%#Container.DataItem("band3")%><br><%#Container.DataItem("band4")%>
</td>
<td width="25%"><font face="tahoma"
size=2><%#Container.DataItem("venue")%><br><font
size=1><%#Container.DataItem("venueadd")%>
</td>
<td width="25%"><font face="tahoma"
size=2><%#Container.DataItem("contact")%>
</td>
</tr>
</table>
<hr color="#E9BEBE">
</AlternatingItemTemplate>
<FooterTemplate>
<!--</table>-->
</FooterTemplate>
</asp:Repeater>
</form>
</body>
</html>
My problem is... in the sub getvenue_click, i have a line saying
SELECT * From gigs where venue = ???, say i put something like
"myselection" in place of ??? How do i define the variable
"myselection"?
Eg. In Visual Basic i would say
dim myvariable
myvariable = MyDDL.Value
i basically need to know the equivelant to that in ASP.
Sorry this post is so long but i thought it might make more sense to
someone if i showed the code for the whole page.
Any help would be appreciated!
Thanks,
Murph
I'm new to ASP.NET and have a problem which i'm hoping will be easy to
answer... i have only used VB, HTML and Flash up until now!
I am designing an ASP page which uses OleDb to retrieve data from an
access database and show it on screen... however, i want the viewer
to be able to select an item from a dropdown menu which relates to
one of the fields and have only that information shown... how do i
declare the variable?
Here is my code:
<%@ Import
Namespace="System.Data.OleDb" %>
<script runat="server">
sub Page_Load
dim dbconn,sql,dbcomm,dbread
dbconn=New
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data
source=" &
server.mappath("gigs.mdb"))
dbconn.Open()
sql="SELECT * FROM gigs"
dbcomm=New OleDbCommand(sql,dbconn)
dbread=dbcomm.ExecuteReader()
gigs.DataSource=dbread
gigs.DataBind()
dbread.Close()
dbconn.Close()
end sub
sub getvenue_click (Sender As Object, E As EventArgs)
dim dbconn,sql,dbcomm,dbread
dim myselection
dbconn=New
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data
source=" &
server.mappath("gigs.mdb"))
dbconn.Open()
sql="SELECT * FROM gigs where venue = ???"
dbcomm=New OleDbCommand(sql,dbconn)
dbread=dbcomm.ExecuteReader()
gigs.DataSource=dbread
gigs.DataBind()
dbread.Close()
dbconn.Close()
end sub
</script>
<html>
<body>
<select id="MyDDL" runat="server">
<option>The Brickyard</option>
<option>Whitehaven Civic Hall</option>
<option>Kendal Rugby Club</option>
</select>
<br><br>
<input type="button"
OnServerClick="getvenue_click" value="Show
Results" runat="server">
<br><br>
<form runat="server">
<asp:Repeater id="gigs" runat="server">
<HeaderTemplate>
<!--<table width="100%">
<tr bgcolor="#AA0000">
<th><font face="tahoma" size=2
color="#FFFFFF">Date</th>
<th><font face="tahoma" size=2
color="#FFFFFF">Line-Up</th>
<th><font face="tahoma" size=2
color="#FFFFFF">Venue</th>
<th><font face="tahoma" size=2
color="#FFFFFF">Contact</th>
</tr>-->
</HeaderTemplate>
<ItemTemplate>
<table width="100%">
<tr bgcolor="#FFFFFF">
<td width="25%"><font face="tahoma"
color="#AA0000"
size=2><b><%#Container.DataItem("date")%></b><br><font
size=1><%#Container.DataItem("doorinfo")%></td>
<td width="25%"><font face="tahoma"
color="#AA0000"
size=2><b><%#Container.DataItem("promoter")%></b><br><%#Container.DataItem("band1")%><br><%#Container.DataItem("band2")%><br><%#Container.DataItem("band3")%><br><%#Container.DataItem("band4")%>
</td>
<td width="25%"><font face="tahoma"
color="#AA0000"
size=2><%#Container.DataItem("venue")%><br><font
size=1><%#Container.DataItem("venueadd")%>
</td>
<td width="25%"><font face="tahoma"
color="#AA0000"
size=2><%#Container.DataItem("contact")%>
</td>
</tr>
</table>
<hr color="#E9BEBE">
</ItemTemplate>
<AlternatingItemTemplate>
<table width="100%">
<tr bgcolor="#FFFFFF">
<td width="25%"><font face="tahoma"
size=2><b><%#Container.DataItem("date")%></b><br><font
size=1><%#Container.DataItem("doorinfo")%></td>
<td width="25%"><font face="tahoma"
size=2><b><%#Container.DataItem("promoter")%></b><br><%#Container.DataItem("band1")%><br><%#Container.DataItem("band2")%><br><%#Container.DataItem("band3")%><br><%#Container.DataItem("band4")%>
</td>
<td width="25%"><font face="tahoma"
size=2><%#Container.DataItem("venue")%><br><font
size=1><%#Container.DataItem("venueadd")%>
</td>
<td width="25%"><font face="tahoma"
size=2><%#Container.DataItem("contact")%>
</td>
</tr>
</table>
<hr color="#E9BEBE">
</AlternatingItemTemplate>
<FooterTemplate>
<!--</table>-->
</FooterTemplate>
</asp:Repeater>
</form>
</body>
</html>
My problem is... in the sub getvenue_click, i have a line saying
SELECT * From gigs where venue = ???, say i put something like
"myselection" in place of ??? How do i define the variable
"myselection"?
Eg. In Visual Basic i would say
dim myvariable
myvariable = MyDDL.Value
i basically need to know the equivelant to that in ASP.
Sorry this post is so long but i thought it might make more sense to
someone if i showed the code for the whole page.
Any help would be appreciated!
Thanks,
Murph