Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old June 28th, 2006, 03:39 AM
Authorized User
Join Date: Jun 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help with SQL - filter for "today"

I am new to asp and sql statements and would appreciate some advice.

I have successfully created a page which displays fields from a database to generate a list of events dates, times, event details and so forth.

What I want to add now is a filter in the SQL statement to display only those records in a given date range. I think I know how to do that, but the complication comes whereby I want the start of range to be "today" and the end of range to be "today" + 30 days.

Here is what I have coded so far as the sql statement and the variable"today" is concerned.

In Code behind file...
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim today As Date = Date.Now()
    End Sub

In SQL query on page displaying results from database(using gridview control)...

SelectCommand="SELECT * FROM [tblDiary] ORDER BY [Short_Date], [Start_Time]"

Essentially how do I pass the value of "today" in my example to a parameter in a "Where" clause of the SQL statement?

Any advice would be greatly appreciated.

Kind Regards.

Old June 28th, 2006, 04:55 AM
Authorized User
Join Date: Jun 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts

Hi There,

Just before attempting to give you a solution, I assume you are wanting to use a SqlDataSource control?


Old June 28th, 2006, 05:15 PM
Authorized User
Join Date: Jun 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts

Hi Rich,
Thanks for your interest.
Actually I am currently using an Access Data Source as this seems to get results whereas I have not so far been able to get results with the SQLdataSource Control. (I am using a database created from MSAccess '97).

I am thinking of persevering with getting the SQLdatasource Control to work at some point however, as I want to exclude the explicit data path reference to my database in my web page, and rely on the details in the web.config file in the way that SQLDatasource control seems to allow.

Sorry if that's a rather long-winded answer to your question.


Similar Threads
Thread Thread Starter Forum Replies Last Post
Trying to do a sql web query/filter u2clone ASP.NET 2.0 Basics 15 July 21st, 2007 08:49 AM
Help for Select SQL Query with date filter pushpa SQL Server DTS 0 February 6th, 2007 10:06 AM
sql date filter keyvanjan Classic ASP Databases 3 March 8th, 2006 10:17 PM
FUNCTION FILTER DATA FROM SQL DATABASE abofoma00 Javascript 1 November 21st, 2005 11:28 AM
importing text file into sql and Filter Easwar VB How-To 1 August 14th, 2005 04:41 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.