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.

  2. 08 Dec 2008 at 09:36
    It is possible to compact and repair when you reference Microsoft Jet and Replication OBJECT library

    'compact Private Sub MenuItem9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem9.Click If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then If IO.File.Exists(ofd.FileName) Then If sfd1.ShowDialog = Windows.Forms.DialogResult.OK Then Dim JRO As New JRO.JetEngine JRO.CompactDatabase("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & ofd.FileName, _ "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sfd1.FileName & ";Jet OLEDB:Engine Type=5") End If End If End If End Sub
  3. 08 Dec 2008 at 09:52
    New path to support library is http://quilt.ic.cz/tmp/upl/Soft.htm#support
  4. 08 Dec 2008 at 09:53
    [http://quilt.ic.cz/tmp/upl/Soft.htm#support](Link to support)
  5. 08 Dec 2008 at 09:53
    another try [link to support](http://quilt.ic.cz/tmp/upl/Soft.htm#support)

Leave a comment

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

Matej Kasper I like freeware, philosophy and art

Related podcasts

  • Software Engineering Radio: SQL with Jim Melton

    Published 1 year ago, running time 1h1m

    Podcast (MP3): Download Hosts: Arno Guests: Jim Melton Recording venue: Skype In this episode, Arno talks to Jim Melton about the SQL programming language. In addition to covering the concepts and ideas behind SQL, Jim shares stories and insights based on his man... sql, episode, in, the

Related jobs

  • Software Engineer (£480 GBP reward)

    Granta Design Ltd in Cambridge, United Kingdom
    £30-40k + health/gym + pension + share options

Events coming up

Want to stay in touch with what's going on? Follow us on twitter or Facebook!