Answered by:
Grid Access DB Select statement using the day of the week # in with where statement

Question
-
User-544860796 posted
Hi,
I am trying to create a grid which will read the data from an access database and select items based on the day of the week. I am using expression web 4.0. I am able to create the grid and have the data populate all the records when I leave off the "where". My problem arises when I try to limit the data using the "where" clause.
I am not sure if I am using the right syntax, dim.
Thanks
Kip
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Page Language="VB" %>
<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Untitled 1</title>
</head><%
Dim dowNumber as integer
Dim dowString as string
dowNumber= Weekday(Today) - 1
dowString= cStr(dowNumber)
%>
<body>
<form id="form1" runat="server">
<asp:GridView id="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ID" DataSourceID="AccessDataSource1">
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True" SortExpression="ID">
</asp:BoundField>
<asp:BoundField DataField="Day" HeaderText="Day" SortExpression="Day">
</asp:BoundField>
<asp:BoundField DataField="Time of Day" HeaderText="Time of Day" SortExpression="Time of Day">
</asp:BoundField>
<asp:BoundField DataField="Start Time" HeaderText="Start Time" SortExpression="Start Time">
</asp:BoundField>
<asp:BoundField DataField="Duration" HeaderText="Duration" SortExpression="Duration">
</asp:BoundField>
<asp:BoundField DataField="Class" HeaderText="Class" SortExpression="Class">
</asp:BoundField>
<asp:BoundField DataField="Location" HeaderText="Location" SortExpression="Location">
</asp:BoundField>
<asp:BoundField DataField="Instructor" HeaderText="Instructor" SortExpression="Instructor">
</asp:BoundField>
</Columns>
</asp:GridView>
<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="../App_Data/synergyDB.mdb" SelectCommand="SELECT * FROM [Schedule] WHERE ([Day] = ?)">
<SelectParameters>
<asp:FormParameter FormField="dowString" Name="Day" Type="Int32" />
</SelectParameters>
</asp:AccessDataSource>
</form></body>
</html>
Thursday, December 9, 2010 6:43 PM
Answers
-
User1716267170 posted
I think you misunderstood the formparameter. It's used like this:
For your code, you need to fire up the selecting event and add the parameter value there. Thanks.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, December 14, 2010 2:41 AM
All replies
-
User1716267170 posted
I think you misunderstood the formparameter. It's used like this:
For your code, you need to fire up the selecting event and add the parameter value there. Thanks.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, December 14, 2010 2:41 AM -
User-1199946673 posted
Because you hardocded the date, you don't need a parameter at all:
SelectCommand="SELECT * FROM [Schedule] WHERE ([Day] = WeekDay(Date()-1))"
Tuesday, December 21, 2010 7:21 AM