Hi there,
Kindly refer to below attached link, hope it helps you to get started with, take care my fren.. :)
http://www.thescripts.com/forum/thread525605.html
************************************************** ******************************************
How do we access an external database from Visual Basic?
To access an external database, we need to have the following items in our project:
1. The Microsoft ActiveX Data Objects Library (version 2.5 upwards)
2. A global variable that is used to connect to the database
3. A command to associate the global variable with the external file
4. An SQL string that specifies what data we would like to obtain from the external file
5. A modular variable (called a Recordset) that contains the output of the SQL statement that we use.
6. A command to fill the Recordset with the results of the SQL statement
From the Menu, go to Project References and the from the list, click on the
entry:
”Microsoft ActiveX Data Objects 2.__ Library” Versions 2.5 and above work fine.
In the main module, in the Option Explicit area, declare the variable as follows:
Public gcn_________ As New ADODB.Connection
In the main module, in the Option Explicit area, declare the variable as follows:
Public gcn_________ As New ADODB.Connection
Name the variable meaningfully, for example, gcnLibrary if you are accessing
the database Library.mdb
In the main module Sub Main(), type in the following code:
‘Find the directory path to the database
If Left(App.Path, 2) <> “\\” Then
ChDrive App.Path
End If
ChDir App.Path
‘Open the connection
gcn____.Open “Provider = Microsoft.Jet.OLEDB.4.0; Data Source = __.mdb”
NOTE: The database (.mdb) file must be in the same directory as the Visual Basic
Project (.vbp) file.
If you are going to display data from the database on a form on Form_Load, type
use this code in the Form_Load() subroutine:
‘create an SQL statement to obtain all records from tbl_______
Dim pst______SQL As String
pst______SQL = “Select * from tbl______”
In the Form’s Option Explicit section, declare a modular Recordset Variable
Option Explicit
Private mrs________ As New ADODB.Recordset
In Form_Load() , after creating your SQL string, fill in the recordset using the
following command:
mrs_____.Open pst__SQL, gcn___, adOpenStatic, adLockOptimistic, adCmdText
Hope it helps...Cheers