Create Microsoft Access Database Connection Visual Basic 6

Now, on this article i will share about Create Microsoft Access Database Connection Visual Basic 6. In here i will use Microsoft access 2007 and Microsoft visual basic 6, where the both programs are programs that are owned by Microsoft. Microsoft Access 2007 is a database application computer used to design, create and process a variety of data types that have a relationship with each other. While Microsoft Visual Basic is a programming language that works within the scope of Microsoft Windows which Microsoft Visual Basic 6 can advantage of the sophistication that is be possessed by the Windows Operating System.

This is The steps we have to do for Create Microsoft Access Database Connection Visual Basic 6 :

  1. Create a database and tables in Microsoft Access 2007
  • Open Microsoft Access 2007 Program, then click New Blank Database

Create Microsoft Access Database Connection Visual Basic 6

  • Then click and change Save as Type to Microsoft Office Access (2002-2003) so database extension change to mdb because this extension already popular with me. If you want to use Microsoft Office Access 2007 Databases then database extension are accdb just different database extension.

Create Microsoft Access Database Connection Visual Basic 6_1

  • Change database named and location want to save the database for this time i saved to C:\Latihan\dbLatihan.mdb
  • And then click the button Create so the database that we had created already to used Create Microsoft Access Database Connection Visual Basic 6. But there are no table in database, we just create connection to that database.

Create Microsoft Access Database Connection Visual Basic 6_2

  1. Create connection in Microsoft Visual Basic 6
  • Open Microsoft Visual Basic 6 Program from the Start Menu then All Programs click Microsoft Visual basic as this picture below :

Create Microsoft Access Database Connection Visual Basic 6_3

  • On window New Project Choose Standard Exe then click button Open

Create Microsoft Access Database Connection Visual Basic 6_4

  • After do the steps above, now we haved project1 and form1. For Create Microsoft Access Database Connection Visual Basic 6 so we need a module connection. Module usually used to contain procedure or function or variable which is general can used in other form on the project environment. For adding module view picture below :

Create Microsoft Access Database Connection Visual Basic 6_5

  • After that will be appear Add Module Window and press button Open and on project Window we have Modules folder and Module1 that was added.

Create Microsoft Access Database Connection Visual Basic 6_6

  • After adding module now we will be add codding for Create Microsoft Access Database Connection Visual Basic 6. Double click on Module1 and adding this code into Module1 :
    
    Public CONN As New ADODB.Connection
    
    Public LokasiDB As String
    
    Public Sub BukaKoneksi()
    
    If CONN.State = 1 Then CONN.Close ' jika koneksi masih terbuka makan akan ditutup
    
    LokasiDB = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & App.Path & "\dbLatihan.mdb"
    
    CONN.Open LokasiDB
    
    End Sub
    
    

    Information :

    If ADODB do not appear so library is not active so that we can not Create Microsoft Access Database Connection Visual Basic 6

Create Microsoft Access Database Connection Visual Basic 6_7

  • After succeed create connection so we will  call Sub Connection that was create with using command  Call<space>Name Sub Connection. For example Call BukaKoneksi, that is  sub connection above.  We can call that Sub Connection on project environment in form.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s