Re: Form Query and GridView for ASP.NET 2.0

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



On Sat, 18 Feb 2006 15:03:37 -0600, "dm1608" <dm1608@xxxxxxxx> wrote:

Hi all --

I'm rapidly learning ASP.NET 2.0 (never really did much .NET before...
mainly an ASP and PHP guy until now) and seem to be having some technical
challenges that I'm hoping someone can help me with.

I've created an n-tier application that consists of a Business Access Lay
and a Data Access Layer to query a SQL Server database. The classes are
stored within my App_Code directory.

The application is a rewrite of one of my earlier ASP applications where I
have a form that a user selects various checkboxes and dropdown lists and/or
types in a text string that will query a database and return all rows that
match that criteria.

One of the changes that I'm making is adding Peter Blum's DataTextBox
controls for a "Start" and "End" date prompt to be used to filter records by
date.

The issue that I'm having is that for some reason, when a user enters a date
such as "02/18/2005" and Peter's DateTextBox.Text property shows
"02/18/2005" and this is the property that I bound my ObjectDataSource to
for the GridView that I'm using. When the date gets passed to my BAL, it is
showing as "02/18/2005 12:00:00 AM". I've tried changing the data type of
the "StartDate" variable to be of type string instead of DateTime and I'm
still getting the same results.

This is causing me issues because if the user wants to query all rows for
today, the StartDate will be 02/18/2005 12:00:00 AM and the EndDate will
also be 02/18/2005 12:00:00 AM which causes no rows to be returned.

I want to somehow get rid of the time and add it to my DAL's SQL
statement... to use 12:00:00 AM for the start time and 23:59:59 for the end
time.

Has anyone else experienced these sort of issues before.

I have even tried changing all my references to StartDate and EndDate to be
of type string... Howver, when I try and do an Add() method to my generic
collection, an exception is thrown about not being able to convert a
DateTime type to a string type; even though I typed-casted the field to a
string.

Any help would this would be appreciated.

When you get the DateTime values from the control, try this:

Assuming the date are DateTime objects:

if the End date is MM/dd/yyy 00:00:00 AM, leave it alone. Then do this: EndDate.AddHours(24);

Now you have a date time range that includes all 24 hours of the end points.

Is that what you want?


Otis Mukinfus
http://www.otismukinfus.com
http://www.tomchilders.com
.



Relevant Pages

  • Re: Complex query criteria - desperate appeal
    ... I made an ASP website using an Access DB ... criteria listboxes have the ALL choice, and the value passed to the query is ... I then build a string of the selected ID's and use ...
    (microsoft.public.access.queries)
  • Re: Query Error
    ... > if a user choose xx char or a string my query gives an error in asp... ... This email account is my spam trap so I ...
    (microsoft.public.inetserver.asp.general)
  • Re: Simple SQL ORDER BY doesnt work!
    ... Access 2k7's Query Builder: incorrect sort order. ... question contains a DATETIME value, and not JUST a date value. ... working correctly (Access and ASP)! ...
    (microsoft.public.inetserver.asp.db)
  • Re: Query Error
    ... > if a user choose xx char or a string my query gives an error in asp... ... This email account is my spam trap so I ...
    (microsoft.public.inetserver.asp.general)
  • Query Error
    ... if a user choose xx char or a string my query gives an error in asp... ...
    (microsoft.public.inetserver.asp.general)