This content is not currently approved and is visible here for review only.

Library tutorials & articles

VB.NET and MS Access

Basics: OleDb Objects

 

About Access databases and VB.NET

Access database may be one of easiest ways in VisualBasic to create database applications, without any needs of heavy instalations (no servers, just db driver MDAC) . You may also only need to install .NET and MDAC everywhere you want to install your application, and transporting data from customer to your machine requires only transfering .mdb file on your flashdisk.

 

 

 

Also there is few minuses:

  • current problems with parallel database connections
    (I wouldn't advice you to use it without some own made request serialiser)
  • execution speed (inserts)
  • inaccessibility to compact & repair function through vb.net
    (after deleting 40M from table, database file stays 40M large until it is "repaired" from Access)
  • and finally worthless password protection.

Namespace, objects

You will find more classes in System.Data.OleDb namespace but I will show you only some paradigms where we will use only few of them:

This is complete set which suffice us to update tables, make structural changes to them and retrieve data from complete scale of SQL:

  • OleDbConnection - class representing connection to our .mdb file, used by all others classes from OleDb namespace
  • OleDbCommand - represents SQL statement or stored procedure executed against db
  • OleDbDataReader - this can we use to obtain data from our SQL selects

This you should know, sometimes to be better and have it more secure, sometimes to do it easier, faster:

  • OleDbTransaction - this is used to secure integrity for multiple data transfers (sometimes is better to store nothing than only part of what we wanted to store - very good programmers are said to transactionise every operation - who knows)
  • OleDbParameter - this can be used to set expressions within SQL statements, or only when setting SQL conflictible string expressions (parameters)
  • OleDbException - you can use it, or let System.Exception which automatically appears when adding Try-Catch exception handling to database commands.

In some cases you may use:

  • OleDbDataAdapter - it can be use as whole one paradigm of accessing table (with its properties InsertCommand, UpdateCommand and DeleteCommand), but when even if you have more types of update etc, it could be still usefull for filling datagrid directly.
  • System.Data: DataTable, DataSet - datatable is usefull mainly for accessing tableschema of given database, but you can use it as it is - in-memory database.

I will be glad to link some other articles about use of DataAdapter, DataTable and DataSet in connection to MS Access or at least connectible, because I've ever sufficed with Conn, Comm and Rdr classes, and my usings of second part was much diletant and primitive :)

sample source code

Comments

  1. 01 Jan 1999 at 00:00

    This thread is for discussions of VB.NET and MS Access.

Leave a comment

Sign in or Join us (it's free).

AddThis

Related podcasts

  • Stack Overflow: Podcast #31

    This is the thirty-first episode of the StackOverflow podcast, where
Joel and Jeff discuss.. stuff!

Based on some comments from Podcast #30, we now know that “Learning about NP-Completeness from Jeff is like learning about irony from Alanis Morissette”. It’s funny b...

Related jobs

Events coming up

  • Jun 16

    Code Generation 2009

    Cambridge, United Kingdom

    A developer event with a practical focus on helping people get to grips with code generation tools and technologies.