Results 1 to 2 of 2

Thread: access and ADO - simple example

  1. #1

    Thread Starter
    Hyperactive Member stingrae's Avatar
    Join Date
    Apr 2002
    Location
    Sydney
    Posts
    401

    access and ADO - simple example

    Hi,

    does anyone have a simple example, or know where to find one, for the following:


    * Using an SQL statement to retrieve data from a table
    * being able to explicitly say which field you wish to see (like the old recordset.fields("fieldname") method

    all the examples i can find only relate to SQL server and not to access.

    thanks all
    "The passion lives to keep your faith, though all are different, all are great" ... Michael Hutchence 1960-1997.

    Windows & Web Developer
    Specialising in Visual Basic .Net & Client Server Programming & Client/Customer Relations Databases
    Sutherland Shire, Sydney Australia
    www.stingrae.com.au
    Developer of Arnold - Gym & Martial Arts Database Management System
    www.gymdatabase.com.au

  2. #2
    Addicted Member
    Join Date
    Jun 2002
    Location
    Brisbane Australia
    Posts
    150

    retreive data from Access tables

    hope this helps. This retreives the next student no from table

    Public Function NextStudentNoGet() As Long
    'get next Student no
    Dim sSql As String
    Dim cn As New OleDb.OleDbConnection(dbcConnection)
    cn.Open()

    'set sql string to reflect search criteria
    sSql = "SELECT LastStudent FROM Startup WHERE ID = 1"

    'open the ADO.NET Datareader
    Dim cmd As New OleDb.OleDbCommand(sSql, cn)
    Dim drd As OleDb.OleDbDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)

    drd.Read()
    NextStudentNoGet = ToNum(drd!laststudent) + 1
    drd.Close()

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