473,770 Members | 5,569 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Date Range lookup between tables in asp 2.0

Hi all,

I am (using ASP.net 2.0 in Visual Web developer 2005 Express Edit) trying to
set up an asp front end to a music DB which has 2 main tables:

1) MUSIC - containing music release information (eg label, artist, name,
date reviewed)
2) ISSUES - containing 3 columns - 1) a list of issue numbers and 2) issue
start date and 3) Issue end date columns

I am (a very novice programmer) having difficulty with presenting search
data in a gridview after a user enters the "date reviewed" details in a text
box and hits a button to perform the search.

user enters date and i am trying to get it to lookup the list of dates in
the second table and return the issue number

i create the textbox and button and then create a gridview connecting back
to the db and am getting stuck from here.

I have tried "ADD WHERE" with various SQL Queries/criteria and thought it
could be done in a "RangeValidator " but have had no joy as the upper and
lower ranges are dependent on what is entered in the textbox and must be
looked up from a separate table. can thios be done in RangeValidator?

one string i tried (which returns everything not just the week in Q) is as
follows:

select NEWMUSIC.MusicI D, NEWMUSIC.MusicR eleaseDate, NEWMUSIC.MusicT itle,
NEWMUSIC.MusicA rtist, NEWMUSIC.MusicL abel, NEWMUSIC.MusicR eviewedDate,
ISSUEDATES.Issu e#
from NEWMUSIC INNER JOIN ISSUEDATES ON NEWMUSIC.MusicR eleaseDate Between
ISSUEDATES.ISSU E_START_DATE and ISSUEDATES.ISSU E_END_DATE

I am really struggling here so would appreciate any assistance!

thanks in advance

Nick
Sep 18 '06 #1
5 1833
I have tried "ADD WHERE" with various SQL Queries/criteria and thought it
could be done in a "RangeValidator " but have had no joy as the upper and
lower ranges are dependent on what is entered in the textbox and must be
looked up from a separate table. can thios be done in RangeValidator?
A range validator can be used to check (validate) user input - for
instance you can use it to ensure that a entered number is between 10
and 20.
one string i tried (which returns everything not just the week in Q) is as
follows:
[...]
You need to join on an id column that exists in both tables not on the
date. I don't know how it's called, it should look like this
(completely untested code):

select
NEWMUSIC.MusicI D,
NEWMUSIC.MusicR eleaseDate,
NEWMUSIC.MusicT itle,
NEWMUSIC.MusicA rtist,
NEWMUSIC.MusicL abel,
NEWMUSIC.MusicR eviewedDate,
ISSUEDATES.Issu e#
from NEWMUSIC
INNER JOIN ISSUEDATES ON
NEWMUSIC.MusicI D = ISSUEDATES.Musi cID
WHERE
ISSUEDATES.ISSU E_START_DATE NEWMUSIC.MusicR eleaseDate
AND
ISSUEDATES.ISSU E_END_DATE < NEWMUSIC.MusicR eleaseDate

Sep 18 '06 #2
hi,
seems to me that there is no relationship between the two tables, so you
can't do a relational join on them. i'm not surprised you're getting too
many records.

from your question, it looks like you only want the issue number, so i would
change your query to something like this:

select ISSUEDATES.Issu e#
from ISSUEDATES WHERE [UserDate] Between
ISSUEDATES.ISSU E_START_DATE and ISSUEDATES.ISSU E_END_DATE
i've never used the Between operator with the first operand as the
user-provided one, so if the above doesn't work, you can use this:
WHERE ISSUE_START_DAT E <= [UserDate] AND ISSUE_END_DATE >= [UserDate]

i can't see any sensible way for you to combine an issue row with a music
row as your query attempts to do. you can try to hack together two tables
that have nothing to do with each other, but this gets messy at the best of
times.

my 2 cents advice would be to go and read up on relational databases,
especially "normalisation" , before you go any further with the project. a
poor database design will cause endless maintenance and bugs further down
the road. a good database design means you do your job easier and better in
less time, and you get to go home early :)

hope this helps
tim
"NickCR_04" <Ni******@discu ssions.microsof t.comwrote in message
news:66******** *************** ***********@mic rosoft.com...
Hi all,

I am (using ASP.net 2.0 in Visual Web developer 2005 Express Edit) trying
to
set up an asp front end to a music DB which has 2 main tables:

1) MUSIC - containing music release information (eg label, artist, name,
date reviewed)
2) ISSUES - containing 3 columns - 1) a list of issue numbers and 2) issue
start date and 3) Issue end date columns

I am (a very novice programmer) having difficulty with presenting search
data in a gridview after a user enters the "date reviewed" details in a
text
box and hits a button to perform the search.

user enters date and i am trying to get it to lookup the list of dates in
the second table and return the issue number

i create the textbox and button and then create a gridview connecting back
to the db and am getting stuck from here.

I have tried "ADD WHERE" with various SQL Queries/criteria and thought it
could be done in a "RangeValidator " but have had no joy as the upper and
lower ranges are dependent on what is entered in the textbox and must be
looked up from a separate table. can thios be done in RangeValidator?

one string i tried (which returns everything not just the week in Q) is as
follows:

select NEWMUSIC.MusicI D, NEWMUSIC.MusicR eleaseDate, NEWMUSIC.MusicT itle,
NEWMUSIC.MusicA rtist, NEWMUSIC.MusicL abel, NEWMUSIC.MusicR eviewedDate,
ISSUEDATES.Issu e#
from NEWMUSIC INNER JOIN ISSUEDATES ON NEWMUSIC.MusicR eleaseDate Between
ISSUEDATES.ISSU E_START_DATE and ISSUEDATES.ISSU E_END_DATE

I am really struggling here so would appreciate any assistance!

thanks in advance

Nick


Sep 18 '06 #3
Hi guys thanks for the help thus far

re normalisation i understand what that means just figured the way i set it
out was the best structure/design:

1 table detailing music release information (including release date)
a 2nd table detailing magazine issue number and start and end dates for the
week it hits the streets (ie a weekly magazine)
goal is for a user to be able to enter a date in text box/search field hit a
button and it automatically can work out what week and issue it falls within
and display that along with the other info on each music item.

re the code markus still struggling to get it to work within the asp - see
below for an attempt to add it near the connection string details for the
datagrid that will display the info. am really stuck here so sorry if this is
really obvious for you seasoned designers!

<asp:SqlDataSou rce ID="releaseweek SqlDataSource1" runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:MUSICConnect ionString1 %>"
SelectCommand=" SELECT * FROM [NEWMUSIC] WHERE
([MusicReleaseDat e] = @MusicReleaseDa te)and select [Issue#] from [issues]
INNER JOIN ISSUEDATES ON NEWMUSIC.MusicI D = ISSUEDATES.Issu e#
WHERE [ISSUE_START_DAT E] >= [MusicReleaseDat e] AND
ISSUEDATES.ISSU E_END_DATE < NEWMUSIC.MusicR eleaseDate"
<SelectParamete rs>

thanks again!
Sep 18 '06 #4
What exactly is your problem now? Binding the result of the query to a
GridView?

-Markus

Sep 19 '06 #5
yup the syntax of getting that into the aspx doc (vs a straight SQL query)
and where it should be positioned?

can I do it in the GUI dev tool and specify the select statement for the
gridview?

if so how?

thanks again!
"Markus Palme" wrote:
What exactly is your problem now? Binding the result of the query to a
GridView?

-Markus

Sep 19 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
5619
by: CoreyWhite | last post by:
The future of computer architecture will use lookup tables. Currently computer processor speed outweighs the benefits of using computer memory for lookup tables, except in some cases. As computer memory increases, new ROM chips will be built with lookup tables hardcoded into them. Here is an example of what using a lookup table can do for you. The following program divides to integers from 0 to 4 using lookup tables and times itself...
6
6090
by: BlackFireNova | last post by:
Using Access 2002 I am writing a report which draws data from several different tables. I can't link all the tables in a query, as some can not be related without truncating the data. I plan to use sub-queries and sub-reports to filter and display the data in the unrelated tables in my report. The common information is a user-inputed date range. I want to avoid having the user prompted for the and variables repeatedly. Somehow I...
1
1596
by: FatBoyThin | last post by:
I love it when I back myself into a corner. Seems to be the fastest way to learn. I have 3 tables; tblINBOX, tblOUTBOX and tblPENDING The relevant rows are as following; Date, userID userID is a 5 digit number I understand how to construct a query to return a count of the userID for a date range for a single table. I'm stumped on how to get a single query that will give me the count of the userID for a date range.
3
2922
by: my-wings | last post by:
I've been reading about how evil Lookup fields in tables are, but I've got to be missing something really basic. I know this subject has been covered before, because I've just spent an hour or two reading about it on google, but there is something I still don't understand, and I'm hoping someone will be willing to explain it to me in small words. Let's say I have a table for addresses, and it includes a field for state. What I would...
3
10666
by: google | last post by:
I have a database with four table. In one of the tables, I use about five lookup fields to get populate their dropdown list. I have read that lookup fields are really bad and may cause problems that are hard to find. The main problem I am having right now is that I have a report that is sorted by one of these lookup fields and it only displays the record's ID number. When I add the source table to the query it makes several records...
10
2252
by: RoadRunner | last post by:
Hi, I have a employee vacation database that has a vacation table that has the employee name, pay week and date of vacation. I have another lookup table with pay week code and date range for the week. The user would like to type in a date in the Date of Vacation field and have the Pay Week field automatically fill in. My dlookup code is not working. Here is example of what the tables look like: Employee: Name Pay Week Date of...
6
1563
by: vdicarlo | last post by:
I am a programming amateur and a Python newbie who needs to convert about 100,000,000 strings of the form "1999-12-30" into ordinal dates for sorting, comparison, and calculations. Though my script does a ton of heavy calculational lifting (for which numpy and psyco are a blessing) besides converting dates, it still seems to like to linger in the datetime and time libraries. (Maybe there's a hot module in there with a cute little function...
3
5994
by: Harlequin | last post by:
I must start this posing by making the point that I am NOT a VB programmer and I'm something of a Newbie to MS Access. I can program in a number of languages (Java, Javascript, PERL,PHP and TCL) but have never actually learnt VB so my request is that you bear this in mind if you plan on replying to this post. My request for help is as follows: I have an MS Access database in which one of the tables within it contains two date fields called...
2
1838
by: wevans | last post by:
I have 3 tables, Customer, Offsite Service and service. I need to create a sales report/query based on the results of the user input, which is a date range. I've got it working great with two of the tables, but not the third. Here's the code for the working one I have now. SELECT ., ., First(.Date) AS , Sum(.Price) AS Price FROM INNER JOIN ON .ID = .ID GROUP BY ., ., . HAVING (((First(.Date))>= And (First(.Date))<)) ORDER BY .; Now...
0
9592
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10231
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10059
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10005
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8887
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7416
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5452
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3576
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.