Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

retrieve data based on data range

Status
Not open for further replies.

skw8966

Programmer
Apr 12, 2001
59
US
I have two textboxes (txtStartDate and txtEndDate). I would like to pull all data between those dates in a gridview. I can't seem to get the procedure to trigger.

Code:
<%@ Page Language="vb" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Variable Weekly Data</title>
</head>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<table>
  <tr>
    <td align="right">
      Start Date:
    </td>
    <td align="left">
      <asp:TextBox ID="txtStartDate" Runat="server" />
    </td>
    <td align="center">
      <a href="javascript:;" onclick="window.open('popup.aspx?textbox=txtStartDate','cal','width=250,height=225,left=270,top=180')">
      <img src="images/SmallCalendar.gif" border="0"></a>
    </td>
  </tr>
  <tr>
    <td align="right">
      End Date:
    </td>
    <td align="left">
      <asp:TextBox ID="txtEndDate" Runat="server" />
    </td>
    <td align="center">
      <a href="javascript:;" onclick="window.open('popup.aspx?textbox=txtEndDate','cal','width=250,height=225,left=270,top=180')">
      <img src="images/SmallCalendar.gif" border="0"></a>
    </td>
  </tr>
</table>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
    DataSourceID="AccessDataSource1">
</asp:GridView>
<asp:AccessDataSource ID="AccessDataSource1" runat="server" 
    DataFile="~/OrderCount.mdb" 
    SelectCommand="SELECT * FROM [qry3McWkCountRevised] WHERE (([RecDate] >= ?) AND ([RecDate] <= ?))">
    <SelectParameters>
        <asp:QueryStringParameter Name="RecDate" QueryStringField="txtStartDate" 
            Type="DateTime" />
        <asp:QueryStringParameter Name="RecDate2" QueryStringField="txtEndDate" 
            Type="DateTime" />
    </SelectParameters>
</asp:AccessDataSource>
</form>
</body>
</html>

Any ideas?
 
As Jason stated in your last post, do not use datasource controls.

You should look at using MS data access blocks.
 
Could you please explain what you mean by not using datasource controls?
 
The access datasource control:
Code:
<asp:AccessDataSource ID="AccessDataSource1" runat="server" 
    DataFile="~/OrderCount.mdb" 
    SelectCommand="SELECT * FROM [qry3McWkCountRevised] WHERE (([RecDate] >= ?) AND ([RecDate] <= ?))">
    <SelectParameters>
        <asp:QueryStringParameter Name="RecDate" QueryStringField="txtStartDate" 
            Type="DateTime" />
        <asp:QueryStringParameter Name="RecDate2" QueryStringField="txtEndDate" 
            Type="DateTime" />
    </SelectParameters>
</asp:AccessDataSource>
 
According to the microsoft site, one of the requirements for using data access is a database server running SQL Server 7.0 or later. I'm using MS Access 2003. Do I have any other options?
 
I'm also using Visual Web Developer not Visual Studio
 
I don't know that to be the case, but if you read it then try using other data objects such as a dataadapter.
 
write the code. the more markup you write the less control you have over your app and the less debugging you can do. and unit testing it's an option at all.

use the code behind to set the datasource and bind the grid to the data. You may also run into problems using an access database on a web application because of the lock files and such. Access is best used for small, local, single user applications.

also MS' website is the worst place to find examples of good design patterns and practices. There site is great for finding out what an object does, but how to use that object is totally different. case in point XDataSourceControl. MSDN is great to find out what it does and all the members, but these controls are the worst idea ever.

My experience is WebForms encourages bad design. The more I work with them the more I fight the page life cycle.
1. it promotes drag/drop for html with serverside webcontrols
2. it creates a page life cycle doesn't exist anywhere else in web development
3. 99% of the examples promote the use of putting all the logic in the code behind. Which means you cannot unit test.
4. Webforms and webcontrols require parameterless ctors, which means inversion of control is either not supported, or requires noisy default ctors.

i'll get off my soap box now. In the end delete the asp:AccessDataSource control from your webform. enter the code behind and manually wireup the events and data to the grid.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top