Hello all,

I'm new to What I've learnt is to handle the database visually or on windows application form. What I want to learn is to handle an MS Access database in coding. Actually I want to add a new class to my project that would contain certain methods to access the data in a way depending on their nature. Though, I've went through some books demonstrating the following method or similar to this:

Imports System.Data.OleDb
Imports System.Data
Public Class Class1
Dim ConString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data

Source=" & "D:\Access DBs\test POS.mdb"
Dim connection1 As OleDbConnection = New OleDbConnection(ConString)
Dim command1 As OleDbCommand = New OleDbCommand("select 2 from


End Class

But I couldn't understand all this procedure completely.
According to my idea, connection string shows the location of the database file which will be connected through a connection object. I've an idea of SQL commands but don't know how to execute them using Oledbcommand object. Simply, the problem I'm is that I don't know the
next step. If I write the further lines of code like:

or something other that are supposed to be next, a blue line appears stating that there is an error in the written line. Could anybody indicate that what is the mistake i'm making or what is the next step in order to access database successfuly Is there any easy tutorial or book that covers this topic nicely
Any useful reply will be appreciated.

Re: Visual Basic General MS Access Database handling in code.


VB.NET uses something called ADO.NET to implement database access code. ADO.NET is database agnostic meaning that the object model is the same for accessing different database types. The only things that should change are the connection string you provide and the slightly different SQL commands you may send to the database as there are different flavours of SQL.

That said some simple ADO.NET examples are at the following

You'll notice that these examples use the SQL optimized versions of ADO.NET Class.

Access cannot use these but there are a more general version of the classes of OleDb which you will see have a names ( connection, command, dataset, datareader, dataadapter) and are detailed in the following articles.

These should get you going with writing code using the ADO.NET Classes allowing database code to be written without using any of the visual elements.