how to connect ms access in visual bacis

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • belly
    New Member
    • Oct 2006
    • 1

    how to connect ms access in visual bacis

    i want to create a table in access using vb database connection and do manipulations in it


    please help

    M.R.AMARNATH
  • vinci
    New Member
    • Aug 2006
    • 62

    #2
    helo friend!

    you can use ADODB or ADODC to connect your database.
    that is what am doing when i make connections.

    you must first add MIcrosoft OLE data objects 2.8 (something like that) in your reference.
    to add ADODC object, in your components you must check Microsoft active data objects. the adodc object will then be available in your toolbar.
    then configure your adodc, you can use UDL, DSN (ODBC), or connection string.

    bout adodb, you actually do codes for connections

    [CODE=vb]'sample:

    dim con as ADODB.Connectio n
    dim rs as ADODB.Recordset

    'then to make the connection

    con.open "Provider = Microsoft.Jet.O LEDB.4.0; data source = (place here the path of your database)"

    ' with rs, this is where you write ur SQL
    ' sample

    rs.open "SELECT * FROM TABLE_NAME", con, 3, 3[/CODE]

    this is basically what i do with my connections...
    hope this could help you...

    just search the net about ADODC and ADODB...

    enjoy programming!
    Last edited by Killer42; Jun 23 '07, 01:37 AM. Reason: Added [CODE=vb] tag

    Comment

    • joco
      New Member
      • Jun 2007
      • 1

      #3
      hlo vinci
      what should i done to delete, update, save, edit
      the files in connecting ms acces to visual basic.
      can you give me a sample program?

      mr. Joco Costanilla

      Comment

      • Devendra Karanjit
        New Member
        • Jun 2007
        • 1

        #4
        Originally posted by joco
        hlo vinci
        what should i done to delete, update, save, edit
        the files in connecting ms acces to visual basic.
        can you give me a sample program?

        mr. Joco Costanilla
        Please use ADOX. Here is a sample program. first reference to msadox.dll at sytem file and use the following code.
        [CODE=vb]Sub AddTable(tablen ame As String)
        Dim tbl As New Table
        Dim cat As New ADOX.Catalog
        Dim idxNew As New ADOX.Index

        'Open the catalog.

        cat.ActiveConne ction = ActconnectionSu bject
        tbl.Name = tablename

        tbl.Columns.App end "QN", adInteger
        tbl.Columns.App end "ChapCode", adInteger

        tbl.Columns.App end "Question", adLongVarWChar
        tbl.Columns.App end "OptionA", adLongVarWChar
        tbl.Columns.App end "OptionB", adLongVarWChar
        tbl.Columns.App end "OptionC", adLongVarWChar
        tbl.Columns.App end "OptionD", adLongVarWChar
        tbl.Columns.App end "CorrectAnswer" , adInteger
        cat.Tables.Appe nd tbl
        End Sub[/CODE]
        Last edited by Killer42; Jun 23 '07, 01:38 AM. Reason: Added [CODE=vb] tag

        Comment

        • Saf4
          New Member
          • Nov 2007
          • 1

          #5
          hi guys,

          I was wandering if anyone could help me out im trying to connect my visual basic project to access databse table, where it has to check if the username and password exit can some one please help me out.

          Comment

          • lotus18
            Contributor
            • Nov 2007
            • 865

            #6
            Originally posted by Saf4
            hi guys,

            I was wandering if anyone could help me out im trying to connect my visual basic project to access databse table, where it has to check if the username and password exit can some one please help me out.

            Comment

            Working...