Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 28th, 2006, 03:39 AM
Authorized User
 
Join Date: Jun 2006
Location: , , United Kingdom.
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.





Reply With Quote
  #2 (permalink)  
Old June 28th, 2006, 04:55 AM
Authorized User
 
Join Date: Jun 2006
Location: Manchester, , United Kingdom.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi There,

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

Rich

Reply With Quote
  #3 (permalink)  
Old June 28th, 2006, 05:15 PM
Authorized User
 
Join Date: Jun 2006
Location: , , United Kingdom.
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.

Regards,





Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 06:59 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.