Simple selecting records from access table

Posted on 2009-04-16
Last Modified: 2013-11-26
Visual Studio 2008

I am having a very hard time understanding .net vs VB6 or vbscript in terms of selecting records from an access database.

Normally all I need to do is this:

ConStringLoginSQL = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\mydatabase.mdb"
Set objConn = Server.CreateObject("ADODB.Connection")       
objConn.ConnectionString = ConStringLoginSQL
Set objRS = Server.CreateObject("ADODB.Recordset")      
strSQL = "SELECT * FROM TableName"      
Set objRS= objConn.execute(strSQL)      

      While not objRS.eof

            MyVariable = objRS("MyField")


set objRS=nothing
set objConn=nothing

That allows me to manipulate, store or do whatever with the data individually as I am looping through the records.

With .Net all I can find examples of are loading data in to "datashapes" and "grids" all at once.
I dont understand.. how am I supposed to manipulate data this way?
I do not need to show the data only compare and make calculations and such.

what am I missing here?

Can someone show me how to do it the "old way" with .net
(note, it's Visual studio 2008, not 2003 or 2005)

Question by:EGormly
    LVL 48

    Accepted Solution

    You can find some generic examples how to handle data, some using parameters:
    For what you want you can use a OleDbCommand.ExecuteReader Method

    Author Comment

    This worked perfectly...

        Using connection As New OleDbConnection(connectionString)
            Dim command As New OleDbCommand(queryString, connection)


            Dim reader As OleDbDataReader = command.ExecuteReader()
            While reader.Read()
            End While
        End Using

    thanks for the link and the OleDbCommand.ExecuteReader Method

    Author Closing Comment

    Excellent Link, I never came across that one. Perfectly fits my situation.
    LVL 48

    Expert Comment

    Glad I could help!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Normally the drop down box control found in the .Net framework tools is able to select just one data and value at a time, which is displayed on the text area.   But what if you want to have multiple values to be selected in the drop down box? As …
    Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    759 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

    8 Experts available now in Live!

    Get 1:1 Help Now