.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Finding the data within a particular range

Posted By:      Posted Date: September 06, 2010    Points: 0   Category :ASP.Net
I need to create a report that will show the list of data that is within that range of period. The scenario will be: - the user will choose the starting month and the ending month from a drop down list. (for example, starting month = July and ending month = September) - then the report will be showing all the data within that range of month chosen by the user. (data from July until September will be shown, including data from the month of AUGUST) - the problem I'm having is that when I choose the starting month and ending month as shown above, I only get the data from the month of JULY and the month of SEPTEMBER, the data from month of AUGUST will not be shown. I'm not sure on how to write the SQL statement??? Needed help from anyone who knows how to solve this porblem.. Thank you..

View Complete Post

More Related Resource Links

Export Data to Excel Based on Date Range

I have data from multiple tables that I would like to display in a gridview via a stored procedure.  I need to select the data based on a date range and display it.  Once displayed I need to include a button that would allow the user to export the gridview data to an excel spreadsheet.  Does anyone have an out of the box solution or know of a tutorial I can use to accomplish this feat?  I am currently using 2.0 for this project. I am newish to .net. Thanks in advance. Here is my stored procedure that calls the data from multiple tables.USE [DATABASENAME] GO /****** Object: StoredProcedure [dbo].[GetUsersAll] Script Date: 09/03/2010 08:20:23 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[GetUsersAll] AS SELECT aspnet_Users.UserName, aspnet_Membership.Email, Team.Name, MemberTeamRole.InsertDate, MemberTeamRole.ManagerApprovedDate, MemberTeamRole.RegistrarApprovedDate, MemberTeamRole.RoleName, MemberInfo.firstname, MemberInfo.lastname FROM aspnet_Membership INNER JOIN aspnet_Users ON aspnet_Membership.UserId = aspnet_Users.UserId INNER JOIN MemberInfo ON aspnet_Users.UserId = MemberInfo.memberid LEFT OUTER JOIN MemberTeamRole ON aspnet_Membership.UserId = MemberTeamRole

Finding table data partition bounds key values using SQL

I have a table that has few million rows and I need the front end application to partition all the data for this table, or any other large table, using sql where clauses so I can retrieve all the data for the table in different threads for each "partition" in parallel (I can't/do not need to know whether the table data is actually partitioned on any specific column at the server). Assume that each "partition" can have n rows (dynamically), is there an easy way of find out what are the bounds for such partitions in terms of the table PK/unique index? Example, create table table_test (col1 char(8) primary key); Example table data: col1 (PK) a b c d e f g   The bounds for table_test for partitions of 2 rows would be four partitions that have the following values for col1: c, e, g  and the font end app would be able to use these bound to generate sql such as: select * from test_table where col1 < 'c'; -- first partition select * from test_table where col1 >= 'c' and col1 < 'e'; -- second partition select * from test_table where col1 >= 'e' and col1 < 'g'; -- third partition select * from test_table where col1 >= 'g'; -- fourth partition So the question is whether the values 'c', 'e', 'g' bounds of the table data can be easily determined by using sql by the client font end.        Farid Zidan Zi

Filter External List by a range of data

I have an external list web part that I am currently using a choice filter on to filter by a certain status.  The options are yes, no, or (empty).  However, I would like to be able to add an additional option to filter where the person has the previous status set to no, but has a value in a different field greater than 90. I realize that the choice filter probably wouldn't do this, and that I could do this easily with separate list views, where I have some sort of web part that can change the list views on the fly. I would think I could use one of those list filters to do this, but when I tried to do that for my original problem, I was unable to connect the filter to my external list. I could connect the list view filter to any internal list without an issue however.  Somebody commented on my old thread that I posted as cptInsane0 that I could just make an infopath view form that has buttons that do this.  I have dabbled with infopath a little bit, but I wasn't able to get infopath to connect to my external list either.  I first had to connect to an internal one, and then for some reason I could add the external list as an alternate data source. I can't be the first person who has had this issue. Could someone point me in the right direction?

Can Attribute limit the data range?

Can I write something like    public struct ID { public SerialPort port; [Range(0,31)] public int siteNumber;<span style="white-space:pre"> // limited to [0, 31] }   to ask Attribute to check the data range? Does .NET provide predefined attribute to do such thing? Or, who can give some suggestions to do such check/limit ? Thank you very much!

Concat and Conversion of char data type to smalldatetime data type resulted in an out-of-range small




I am trying to create a new date as below and add this date to the BDMRY field (smalldatetime data type) in SQL Server 2005.

MostRecentCompletionDate -  (smalldatetime data type)

StudentBirthdate - (smalldatetime data type).

SET BDMRY =  CAST(CAST(YEAR(MostRecentCompletionDate) AS VARCHAR(4)) + '/' +
                      CAST(MONTH(StudentBirthdate) AS VARCHAR(2)) + '/' +
                      CAST(DAY(StudentBirthdate) AS VARCHAR(2)) AS DATETIME)

When I run this I'm getting the error as:

Msg 296, Level 16, State 3, Line 1
The conversion of char data type to smalldatetime data type resulted in an out-of-range smalldatetime value.
The statement has been terminated.

It works fine on my laoptop but doesnt work on the production server.

Any help would be greatly appreciated.



problem with date range between select Query in data adapter


hi all,

can any one help me out...why am getting "data type mis match error"

 DateTime dFromDate = dt_From.Value;
            dt_From.Value = DateTime.Parse(dFromDate.ToShortDateString());
            string From = dFromDate.ToShortDateString();

            DateTime dToDate = dt_To.Value;
            dt_To.Value = DateTime.Parse(dToDate.ToShortDateString());
            string To = dToDate.ToShortDateString();
            OleDbConnection cn = new OleDbConnection(ConfigurationSettings.AppSettings["connec"]);
            OleDbDataAdapter da = new OleDbDataAdapter("select * from Route_Expenses a where Entry_Date between '" +From+"' and '"+To+"'",cn);
            DataSet ds = new DataSet();
            dataGridView1.DataSource = ds.Tables[0];

 Please..its Urgent!

adhoc reporting - data doesn't refresh on date range change


I created an adhoc report model using SQL Server 2008 reporting services. I am using data from a SQL 2000 database sitting on a SQL 2000 server. I created reports with start date and end date parameters, everything worked fine.


Now my ad hoc report model uses a SQL 2000 database (this database is a replication of the database I was using)  sitting on a SQL 2008 server. When I change parameters like start date and end dates, data doesn’t refresh. It shows the same data for any date range.


Has anyone seen this problem? What could be done to fix the issue. Is there any setting on the SQL server to fix this?



displaying a range of data in detailsview.


hi all , I am an absolute beginner and do not as such write code with any confidence yet.  I am persevering with visual developer express 2010 whilst learning visual basic from hello world stage onward. In the meantime I have a difficulty . I am trying to display a range of data in details view which is being fed a parameter from a dropdown  list. I cannot seem to come up with a query that will pull over all data from a column that is less than a certain number and then display it with distinct values in the dropdown. for example I would like say to pull over height data where it displays all data below  20m all data below 30m etc. is this possible without heavy coding? 

I want to fetch the data between the give date range from ms sql 2005 database



I am developing one desktop application using vb.net 2008 and Microsoft SQL Server 2005. I need a help for fetching the data from database between a given range.


the date field in my table is of type VARCHAR(25) and the date format stored is dd-mm-yyyy. when I using the between clause in the SQL query then it is not giving all the data every time i.e. the date criteria in where clause is not working fine.

while my clients requirement is to keep the date format as dd-mm-yyyy and fetch the data according to the given range.

I search on the forum and found many queries to fetch the data by converting or type casting the date field within sql query but nothing worked.

so please help me out with that what shoud I do in this case.

The table structure that I am using is as follows


USE [Firm_master]
/****** Object:  Table [dbo].[tblTransaction]    Script Date: 05/17/2011 21:49:11 ******/
CREATE TABLE [dbo].[tblTransaction](
    [Tid] [int] IDENTITY(1,1) NOT NULL,
    [Dataid] [int] NOT NULL,
    [Vouch_type] [int] NULL,
    [Dr_ac_name] [varchar](50) NULL,

Binding WPF Controls to an Entity Data Model

In this interview, programming writer, McLean Schofield, demonstrates how to bind WPF controls to an entity data model, using Visual Studio 2010 Beta 1. You can also learn more in the topic: Walkthrough: Binding WPF Controls to an Entity Data Model.

Surrogate vs Natural Primary Keys - Data Modeling Mistake 2 of 10

In case you're new to the series I've compiled a list of ten data modeling mistakes that I see over and over that I'm tackling one by one. I'll be speaking about these topics at the upcoming IASA conference in October, so I'm hoping to generate some discussion to at least confirm I have well founded arguments.

The last post in this series Referential Integrity was probably less controversial than this one. After all, who can argue against enforcing referential integrity? But as obvious as surrogate keys may be to some, there is a good deal of diversity of opinion as evidenced by the fact that people continue to not use them.

Editing the Data in a GridView

In addition to deleting a GridView's underlying data, another common need is to allow end users to edit the data displayed in a GridView. With ASP.NET 1.x's DataGrid control, editing the data is certainly possible, but requires creating three event handlers and writing a dozen or so lines of code. With the GridView and ASP.NET 2.0, it is possible to create an editable GridView without writing a single line of code! All of the necessary functionality is encapsulated within the GridView.

The GridView allows editing on a row-by-row basis. An editable GridView contains an additional column with an Edit button in each row. When the end user clicks on an Edit button that row becomes editable, causing the Edit button to change to Update and Cancel buttons and the other columns to become TextBoxes. The end user can then update one or more column values and click Update to save their changes.

Using ASP.NET 3.5's ListView and DataPager Controls: Displaying Data with the ListView

Prior to ASP.NET 3.5, developers who needed to display a set of records could choose between the GridView, DataList, and Repeater controls. The GridView provides rich data features, but has a very boxy layout; the DataList and Repeater allow for a more flexible layout, but lack the "point and click" data features found in the GridView, DetailsView, and FormView controls. The ListView bridges the gap between layout flexibility and built-in data features.

This article, the first in a series of articles on the ListView and DataPager controls, looks at the ListView's many available templates and illustrates how to display data. Read on to learn more!

Dynamic Data Templates in GridView ASP.NET 3.5

At a high level, Dynamic Data Templates can be seen as a system to very quickly build up a User Interface linked with the relevant data model, immediately enabling you to perform CRUD operations (Create, Read, Update, Delete) on the database using the specified data source. They provide a powerful method for building up these kinds of applications, and I'm going to focus on an overview of what Dynamic Data Templates actually are, and a few ways of customizing them to suit industry needs.

MS SQL Server: Search All Tables, Columns & Rows For Data or Keyword Query

If you need to search your entire database for specific data, this query will come in handy.

So when a client needs a custom report or some sort of custom development using Great Plains, most of the time I will have to track down the data in the system by running this query and find the table(s) it is in.

Displaying Data using ASP.NET 2.0 Repeater and C#

This tutorial will show you how to display data using the .NET Repeater Control, ASP.NET 2.0 and C#.NET

The Repeater control is a powerful tool and is easy to use.

First, you will need to import the System.Data.SqlClient namespace.

MVC architecture in ASP.Net using C# and Microsoft Data Access Application block

The Model-View-Controller (MVC) pattern separates the modeling of the domain, the presentation, and the actions based on user input into three separate classes [Burbeck92]:

Model. The model manages the behavior and data of the application domain, responds to requests for information about its state (usually from the view), and responds to instructions to change state (usually from the controller).

View. The view manages the display of information.

Controller. The controller interprets the mouse and keyboard inputs from the user, informing the model and/or the view to change as appropriate.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend