Repetitive Searching Of A Database

jsurpless

Well-known member
Joined
Jul 29, 2008
Messages
144
Programming Experience
Beginner
Hi everyone

First off, sorry if this question has been asked elsewhere on the forum; I tried looking around but I'm not quite sure what I'm looking for so...

I've got an MS Access table that I want to reference in my program... I have a number of AutoCAD files that I'm looping through and I've figured out how to retrieve only the records from the database that pertain to the current file...

VB.NET:
For Each strAutoCADFilePath In strAutoCADFilePaths

  Console.WriteLine("Processing AutoCAD Drawing File '" & strAutoCADFilePath & "'")

    'If the user has specified an 'Instance Drawing' database field
    If (c_Database.InstanceDrawing_Field <> "") Then

      Dim strAutoCADFile As String = Replace(Path.GetFileName(strAutoCADFilePath), ".dwg", "")

      c_Database.DatabaseInformationTable_SQLWhere = "WHERE [" & c_Database.InstanceDrawing_Field & "] LIKE '" & strAutoCADFile & "'"

    End If

    DatabaseInformation_Table = c_Database.GetMSAccess_DatabaseInformationTable

    Using DatabaseInformation_Table_Reader As New DataTableReader(DatabaseInformation_Table)

      If (Not DatabaseInformation_Table_Reader.HasRows) Then

        Console.WriteLine("***ERROR*** NO MATCHING DATABASE RECORDS FOUND")

      End If

    End Using

    Console.WriteLine()

  Next

The obvious issue with this is that I hit up the database for each file instance... it gets even worse because I want to search the database for each block in a drawing...

I'm rather new to VB.Net so any help would be most appreciated...

Thanks!
 
It's not clear what your question is, but have a read of DW2 link in my signature, section Creating a Simple Data App, and then Creating a Form to Search Data

You'll see an easier better way of doing your data access
 

Latest posts

Back
Top