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

Database

 
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 
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 
If your primary key is only BusID, how can a single bus have multiple stops? It would need to be listed multiple times (once for each stop), but that wouldn't be allowed by the primary key...

I think I see what you're getting at with the "cross query" you wanted to use - I've never done any of those before, but it seems from what you've said that a cross query returns all records that are present in both tables you're comparing. So what you were originally doing is you had a query which returned all the buses that stopped at the source location and a query which returned all the buses that stopped at the target location? I guess what you could do then is something like this:


TimeSpan tsBest = tsBest.MaxValue;
string strBest = null;
foreach (DataRow drFrom in tblFrom.Rows)
{
// See if the bus is also in the "to" table
DataRow drTo = tblTo.Find(drFrom["BusID"]);
if (drTo != null)
{
// See if the bus stops at the from location *before* stopping
// at the to location (note: will not work if buses run past midnight!)
DateTime dtFromTime = (DateTime)drFrom["StopTime"];
DateTime dtToTime = (DateTime)drTo["StopTime"];
if (dtFromTime < dtToTime)
{
// See if bus leaves with desired range
if (dtFromTime <= dtDesiredMaxFromTime && dtFromTime >= dtDesiredMinFromTime)
{
// found a bus
// note: will not necessarily find the bus CLOSEST to the desired
// departure time, only the FIRST bus listed that is acceptable
strBest = drFrom["BusID"].ToString();
break;

}
}
}
else
{
// no bus goes here to there
strBest = null;
}
}
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 
Generaltext to ntext Pin
ShankarPS20-May-04 16:59
ShankarPS20-May-04 16:59 
GeneralRe: text to ntext Pin
Grimolfr21-May-04 4:17
Grimolfr21-May-04 4:17 

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.