How to create database in & connect MS-ACCESS with VISUAL BASIC?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kumarg
    New Member
    • Sep 2006
    • 3

    How to create database in & connect MS-ACCESS with VISUAL BASIC?

    how to create database in Ms-Access & how to connect that database with
    Visual Basic-6.0, if i work in standalone system? Kindly let me know the details??
  • Rahna
    New Member
    • Aug 2006
    • 12

    #2
    Originally posted by kumarg
    how to create database in Ms-Access & how to connect that database with
    Visual Basic-6.0, if i work in standalone system? Kindly let me know the details??

    Hope this piece of code will help you to get started.

    Dim Ageconn As New ADODB.Connectio n
    Dim Ageset As New ADODB.Recordset

    Private Sub Form_Load()

    Ageconn.Connect ionString = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=D:\MyDB. mdb;Persist Security Info=False"
    Ageconn.Open
    If Ageconn.State <> adStateOpen Then
    MsgBox "Error...!! ! Connection not Open", vbCritical, "Connectivi ty Problem"
    End If
    Ageset.ActiveCo nnection = Ageconn
    Ageset.CursorLo cation = adUseClient
    Ageset.CursorTy pe = adOpenDynamic
    Ageset.LockType = adLockOptimisti c
    Ageset.Source = "select * from MyTable"
    Ageset.Open

    Ageset.AddNew
    Ageset.Fields(0 ) = 1
    Ageset.Fields(1 ) = Name
    Ageset.Fields(2 ) = Address
    Ageset.Fields(3 ) = Phone
    Ageset.Fields(4 ) = PIN
    Ageset.Update

    Ageset.Close
    Ageconn.Close

    Regards,

    Comment

    Working...