EziData Solutions

Web, NET and SQL Server

Retrieving Data from an Access Database

There are a number of easy ways to programmatically retrieve data from an Access database in .NET. The DataReader object is one of the easiest, especially when you need to loop through the data being returned to carry out some calculation or function.

The first step is to create and open a connection to the database using the technique shown in a previous post.

'declare a DataReader

Dim dr As OleDbDataReader 'For an Access database

 

'populate the datareader with the results of the command

dr = cmd.ExecuteReader()

 

'create a loop to read values from the datareader

While dr.Read()

'gain access to the fields using something like below

Dim strValue As String = dr(fieldname).ToString()

End While

 

'close the read when done

dr.Close()

 

Posted: Oct 06 2009, 21:35 by Admin | Comments (0) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under: Access