Dim myFileInfo As System.IO.FileInfo
Dim myConnectionString As String
Dim myOLEDBConnection As OleDb.OleDbConnection
Dim myOLEDBCommand As OleDb.OleDbCommand
Dim myDataAdapter As OleDb.OleDbDataAdapter
Dim myDataSet As New DataSet
Dim myDataTable As New DataTable
Dim myRow As DataRow
Dim myColumnCollection As New Collection
Dim theSurveyDate As Date
Dim theStartTime As DateTime
Dim theEndTime As DateTime
Dim theTrimble As String
Dim theTableName As String
Dim aString As String
'If no filename has been specified
If (DBFfile.Length = 0) Then Return
myFileInfo = New System.IO.FileInfo(DBFfile)
'Determine the trimble form the filename
theTrimble = myFileInfo.Name.Substring(7, 1)
'Determine the table name
theTableName = myFileInfo.Name.Substring(0, myFileInfo.Name.Length - 4)
Try
myConnectionString = "Provider=vfpoledb.1" & _
";DataSource=" & myFileInfo.DirectoryName.Trim & _
";Collating Sequence=General" & _
";Mode=Read"
'Instatiate the database connection
myOLEDBConnection = New OleDb.OleDbConnection(myConnectionString)
'Create the SQL command
myOLEDBCommand = New OleDb.OleDbCommand("SELECT * FROM " & theTableName, _
myOLEDBConnection)
'myOLEDBConnection.Open()
'Open an OLEDB adapter based on the SQL command and use this to
'create a dataset
myDataAdapter = New OleDb.OleDbDataAdapter(myOLEDBCommand)
myDataAdapter.Fill(myDataSet)
'Read the data in the dataset table
For Each myDataTable In myDataSet.Tables
If (myDataTable.TableName.Trim = myFileInfo.Name) Then
For Each aString In myDataTable.Columns
myColumnCollection.Add(aString)
Next
For Each myRow In myDataTable.Rows
theSurveyDate = myRow.Item("SURVDATE")
theStartTime = myRow.Item("STARTTIME")
theEndTime = myRow.Item("ENDTIME")
'Now determine a photograph matching this date
'and time range
Call FindPhoto(theTrimble, theSurveyDate, _
theStartTime, theEndTime)
Next
End If
Next
myDataTable = Nothing
myDataSet = Nothing
myDataAdapter = Nothing
Catch ex As Exception
MsgBox("The following error occured whilst trying to read the photograph file;" & Chr(13) & _
Chr(34) & DBFfile.Trim & Chr(34) & Chr(13) & _
ex.Message, MsgBoxStyle.Exclamation)
End Try
End Sub