CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Finding a field

Threaded View

  1. #1
    Join Date
    Feb 2010
    Posts
    13

    Finding a field

    Hi, need some advice please

    New to Database programming, but what I want to do is update a database everyday with information I am getting from a file

    So what I want to do is the following

    Do until End Of File
    Read ProductCode and ProductDescription from File
    Record = Database.Columns["Code"].Find(ProductCode)
    If no Record found then
    Add a new record with ProductCode and Description
    else
    Update Record // Description may have changed
    End If
    Loop

    The file may contain 4000 to 5000 records and I don't know what the best way is to search the database.

    Would it be to loop through each record testing if ProductCode matches, or is there already a search feature there
    I presume using DataSet.Table["Products"].Select[search criteria] would not be a good choice as its going through the loop so many times?

    The database connection I have is
    Adapter = new OleDbDataAdapter("Select * from Products",
    @"Provider=Microsoft.JET.OLEDB.4.0;data source=C:\Stock.mdb");
    Set = new DataSet();
    Adapter.Fill(Set, "Products");

    I hope this is easy to understand, and I appreciate your help
    Last edited by gmcconville; February 23rd, 2010 at 04:41 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured