Cor,
I must not be doing a bad job of explaining what I am doing or I am
just having trouble understanding all the help I am being given. This
particular problem concerns 3 tables in the database: LCMR, Q36, and
UTAMS. There are only two columns that I am concerned with in each of
these tables: DTG and POO. Each table is around 4000 records and grows
daily.
I am loading what is needed from each table into the dataSet using 3
SQL statements and 3 dataAdapters.
Dim strSQLLCMR As String = "SELECT DTG, POO FROM LCMR WHERE (Confirmed =
true and Friendly = False) ORDER BY DTG"
Dim strSQLQ36 As String = "SELECT DTG, POO FROM Q36 WHERE (Confirmed = true
and Friendly = False) ORDER BY DTG"
Dim strSQLUTAMS As String = "SELECT DTG, POO FROM UTAMS WHERE (Confirmed =
true and Friendly = False) ORDER BY DTG"
daLCMR = New OleDb.OleDbDataAdapter(strSQLLCMR, myConnection)
daQ36 = New OleDb.OleDbDataAdapter(strSQLQ36, myConnection)
daUTAMS = New OleDb.OleDbDataAdapter(strSQLUTAMS, myConnection)
When either of the radars track an attack they may track multiple
projectiles, usually 6 to 8 acquisitions. This adds 6 to 8 entries to
the databasae table. An individual attack is over in less than a minute
most times. Ok, so now I have a dataSet with 3 tables and only the rows
of confirmed acquisitions that were not friendly fire in date time order.
I setup a for next loop to go through each table and compare the current
record to the previous record. If the date/time is within 5 minutes or
the Point of Origin (POO) is within 1000 meters the code considers the
acquisition to be the same. So I have a loop like this for each table in
the dataset.
intLCMRIDF = 0
For Each drLCMR In ds.Tables("LCMR").Rows
If intLCMRIDF = 0 Then
intLCMRIDF = 1
datCurDate = CDate(drLCMR.Item(0).ToString)
intCurEast =
CInt(Microsoft.VisualBasic.Left(drLCMR.Item(1).ToString, 5))
intCurNorth =
CInt(Microsoft.VisualBasic.Right(drLCMR.Item(1).ToString, 5))
End If
If datCurDate > DateAdd(DateInterval.Minute, 5,
CDate(drLCMR.Item(0).ToString)) Or _
datCurDate < DateAdd(DateInterval.Minute, -5,
CDate(drLCMR.Item(0).ToString)) Then
intLCMRIDF += 1
datCurDate = CDate(drLCMR.Item(0).ToString)
intCurEast =
CInt(Microsoft.VisualBasic.Left(drLCMR.Item(1).ToString, 5))
intCurNorth =
CInt(Microsoft.VisualBasic.Right(drLCMR.Item(1).ToString, 5))
ElseIf intCurEast >
CInt(Microsoft.VisualBasic.Left(drLCMR.Item(1).ToString, 5)) + 1000 Or
_
intCurEast <
CInt(Microsoft.VisualBasic.Left(drLCMR.Item(1).ToString, 5)) - 1000
Or _
intCurNorth >
CInt(Microsoft.VisualBasic.Right(drLCMR.Item(1).ToString, 5)) + 1000
Or _
intCurNorth <
CInt(Microsoft.VisualBasic.Right(drLCMR.Item(1).ToString, 5)) - 1000
Then
intLCMRIDF += 1
datCurDate = CDate(drLCMR.Item(0).ToString)
intCurEast =
CInt(Microsoft.VisualBasic.Left(drLCMR.Item(1).ToString, 5))
intCurNorth =
CInt(Microsoft.VisualBasic.Right(drLCMR.Item(1).ToString, 5))
End If
Next
Now I have a count of how may attacks each radar has tracked.
intLCMRIDF = 4
intQ36IDF = 46
intUTAMSIDF = 2
I do not know how many total attacks have occured. Adding these counts
together would not give that because the two tracked by the UTAMS radar was
probably tracked by the Q36 radar also. The same case with the 4 tracked by
the LCMR. So I needed a way to have all three tables combined and sorted by
DTG so I could go through all of them at once and get a total count. Which
wound up being 47. To do this I loaded created another SQL statement and
dataAapter:
Dim strSQLState As String = "SELECT DTG, POO FROM Q36 WHERE (Confirmed =
true and Friendly = False) " & _
"UNION SELECT DTG, POO FROM LCMR WHERE
(Confirmed = true and Friendly = False) " & _
"UNION SELECT DTG, POO FROM UTAMS WHERE
(Confirmed = true and Friendly = False) " & _
"ORDER BY DTG"
daCombine = New OleDb.OleDbDataAdapter(strSQLState, myConnection)
And loaded it into the dataSet in yet another table:
Dim intTotalIDF As Integer = daCombine.Fill(ds, "IDF")
Now I can compare all the tables at once with another For Each / Next loop.
Seems to me like alot of code to do a simple task, but this is where I am at
and it works. I am learning as I go and will gladly take advice and try it
in my situation. It has not taken my long to find that there are 100's of
ways to do different tasks in code. My coding usually strays toward making
it work and then trying to make in more efficent. Probably not a good way,
but a way. This group has been very helpful in my learning and I hope that
you continue.
Thanks,
Thomas