Need help caching a couple of rows from SQL at runtime for lookups

Posted on 2006-05-23
Last Modified: 2010-04-23
I need to cache a lookup table from SQL which will contain roughly 10 rows, at runtime. I also need a function to lookup the data based on the input..
for Example
I cache a table that looks like this
warehouseid   warehousename
1                       new york
2                       florida
3                       california

i then want to look this up quickly without having to go back to the sql to get the data-- as this data is static and does not change often--but hardcoding it would be pretty stupid.....
Question by:moruda
    LVL 34

    Accepted Solution

    Private ds as new dataset


    Private Sub LoadLookup()
       Dim da as new sqldataadapter
       with da
          .selectcommand = new sqlcommand
          with .selectcommand
             .connection = {your connection}
             .commandtext = "SELECT warehouseid, warehousename FROM myTable"
          end with
          .acceptchangesduringfill = true
          .tablemappings.add("Table", "Warehouse")
       end with

       catch ex as exception
"Error Loading Warehouse Data: " + ex.message)
       end try
    end sub

    the data is now loaded into a datatable called "Warehouse" in the ds DataSet
    LVL 19

    Expert Comment

    Its not a Web App right ??

    Author Comment

    it is not a web app. it's

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
    If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    This video discusses moving either the default database or any database to a new volume.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now