Click here to Skip to main content
15,895,283 members
Home / Discussions / Database
   

Database

 
Generalquery inside a dataset Pin
fuel2run24-May-04 21:27
fuel2run24-May-04 21:27 
GeneralRe: query inside a dataset Pin
ekolis25-May-04 9:02
ekolis25-May-04 9:02 
GeneralRe: query inside a dataset Pin
fuel2run25-May-04 21:08
fuel2run25-May-04 21:08 
GeneralRe: query inside a dataset Pin
ekolis26-May-04 10:58
ekolis26-May-04 10:58 
GeneralRe: query inside a dataset Pin
fuel2run27-May-04 4:34
fuel2run27-May-04 4:34 
GeneralRe: query inside a dataset Pin
ekolis27-May-04 10:53
ekolis27-May-04 10:53 
GeneralRe: query inside a dataset Pin
fuel2run27-May-04 21:04
fuel2run27-May-04 21:04 
GeneralRe: query inside a dataset Pin
ekolis28-May-04 9:28
ekolis28-May-04 9:28 
So I suppose you have 3 fields: BusID, StopTime, and StopLocation, let's call them? And the primary key is BusID and StopTime? Why don't you try creating a query, call it BusSchedule, which looks like this:

SELECT * FROM BusStops WHERE BusID = ? ORDER BY StopTime

Now run this query in a foreach loop on BusID, and it will give you the bus's schedule in the standard timetable format. (Assuming StopTime is stored as a DateTime and not as a string!) Now just grab the first and last record from this query

drFirst = dtQuery.Rows[0];
drLast = dtQuery.Rows[dtQuery.Rows.Count - 1];

and compare drFirst["StopLocation"] to your desired start location and drLast["StopLocation"] to your desired end location. If both equalities hold true, then the BusID you just ran the query on is the bus you're looking for and you can break out of the foreach loop.

Is this the answer you're looking for, or do I still not have your table structure right?
GeneralRe: query inside a dataset Pin
fuel2run29-May-04 2:55
fuel2run29-May-04 2:55 
GeneralRe: query inside a dataset Pin
ekolis29-May-04 9:15
ekolis29-May-04 9:15 
GeneralRe: query inside a dataset Pin
fuel2run29-May-04 22:14
fuel2run29-May-04 22:14 
GeneralRe: query inside a dataset Pin
ekolis30-May-04 15:50
ekolis30-May-04 15:50 
GeneralRe: query inside a dataset Pin
fuel2run30-May-04 23:55
fuel2run30-May-04 23:55 
GeneralRe: query inside a dataset Pin
ekolis31-May-04 13:54
ekolis31-May-04 13:54 
GeneralRe: query inside a dataset Pin
fuel2run31-May-04 22:02
fuel2run31-May-04 22:02 
GeneralProblems porting a DataSet from SQL Server to XML Pin
Jordan Breckenridge24-May-04 6:23
Jordan Breckenridge24-May-04 6:23 
GeneralADO and Excel File Pin
bigBA24-May-04 1:45
bigBA24-May-04 1:45 
GeneralRe: ADO and Excel File Pin
-Dr_X-26-May-04 17:17
-Dr_X-26-May-04 17:17 
GeneralDBase file table names Pin
IJay24-May-04 0:27
IJay24-May-04 0:27 
GeneralProblem connecting to sql with C# and ASP.NET Pin
Aviv Halperin23-May-04 10:38
Aviv Halperin23-May-04 10:38 
GeneralRe: Problem connecting to sql with C# and ASP.NET Pin
Grimolfr24-May-04 3:30
Grimolfr24-May-04 3:30 
GeneralConnection String for Database access Pin
Ali Alaradi22-May-04 19:55
Ali Alaradi22-May-04 19:55 
GeneralRe: Connection String for Database access Pin
Hesham Amin23-May-04 11:12
Hesham Amin23-May-04 11:12 
GeneralSQL Pin
Member 110684620-May-04 21:02
Member 110684620-May-04 21:02 
GeneralRe: SQL Pin
Hesham Amin20-May-04 21:48
Hesham Amin20-May-04 21:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.