Visual Basic and Access database

I have an Access database and I can’t access it with Visual Basic
The latter doesn’t allow me to open my Access database from Office 2000

52 answers

  1. How to establish a connection between VB6.0 and an Access database?
    1. YES I’d really like that a lot please!
    2. I have an Access 2003 database that I want to connect to an EXE program. Standard VB6
  2. I believe to display data in a grid or text boxes you should follow my example
    the table being eleve the chomd (name, surname, code and datens)
    1) in the module declare

    Public DB As New ADODB.Connection
    Public rs As New ADODB.Recordset

    2) the form load

    Set cn = New ADODB.Connection
    Set DB = New ADODB.Connection
    cn.Open "provider=Microsoft.jet.OLEDB.4.0; data source=C:\Documents and Settings\Nekor-bit bureau\Mes documents\fiche.mdb;Persist Security Info=False"

    Private Sub Command1_Click()

    If Text1.Text <> "" Then
    On Error GoTo err
    If IsNumeric(Text1) = False Then
    Set DB = New ADODB.Connection
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseServer 'may not be used
    rs.CursorLocation = adUseClient 'very important Without this line, it generates an error 7004
    DB.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Nekor-bit bureau\Mes documents\fiche.mdb;Persist Security Info=False"
    rs.Open "select * from eleve where nom like '" & Text1.Text & "%'", DB, adOpenStatic, adLockOptimistic

    Text2.Text = rs!code
    Text3.Text = rs!nom
    Text4.Text = rs!prenom
    Text5.Text = rs!datens

    Set Adodc1.Recordset.DataSource = rs
    Set DataGrid1.DataSource = rs

    Text1.SetFocus
    End If
    Set DataGrid1.DataSource = rs
    err:
    End If

    bon courage
    1. by Essaouiqui Abdelhakim
  3. hello, first convert your database to Access 97 format, then do:

    -start
    -Control Panel
    -Administrative Tools
    -ODBC Data Sources
    in the box that appears choose "Microsoft Access Driver" then click "Add"
    -in the new box choose System Data Source
    -give your source a name
    -click on "Select the database"
    -choose the location where you saved your project
    -then click OK
    that's the ADO approach.
    1. hi,
      I progressed a bit in my app, I drew the interface in VB6 with the buttons, text box and all that.
      I added an adodc to connect to my MDB database but I can't find the code to add a record since the database already contains records.
      could you please show me the way.
      I linked the adodc with the database in the properties but I still don't know what to do next.
      thanks
      1. Hello, voici ce que tu dois faire :
        tu fais un double clic sur le bouton enregistrer pour taper le code qui va te permettre d'enregistrer tes données depuis vb :
        adodc.recordset.addnew()
        adodc.recordset!Code=txtCode.text
        adodc.recordset!Nom=txtNom.text
        ..........................
        .......................
        adodc.recordet.movenext
    2. Hi, to access your Access database you need to convert your database to Access 97 if you are working with Visual Basic 6.
      1. I am a beginner in Access and VB and I’m trying to create a database. I started with creating tables, forms, and reports, and a few queries. Can someone help me with what comes next... thank you very much.
        1. Hello everyone.

          I installed VB 2008 and I noticed that the Crystal Report component is missing
          please if someone could guide me on how I can add Crystal Report to VB 2008 so that I can work with reports .

          Thanks in advance.
          1. Do you know how to use the ADO command from the toolbox to access your database?

            Asking is wiser than being closed off.
            1. Hello
              I had the same problem
              convert your Access 2000 file to 97 and I think it’s going to work
              regards
              1. How to establish a connection between VB6.0 and an Access database?
                contact me at mounem2010@yahoo.fr
                1. Hi, this is ALBERT. By the way, I have a problem. I’m a student in IG with the Application Developer track. My project is to set up a database on Access and make it active with Visual Basic. Given the loaded course program, I’d like you to help me realize my project as a guide. Thank you in advance and have a good day.
                  1. Hi, I’m a beginner in VB and I have a database connection problem with a VB6 application. Here is my code:

                    Private Sub Command1_Click()
                    With clt
                    .Index = "PrimaryKey"
                    <---------- the error is here!!
                    .Seek "=", num.Text
                    If .NoMatch Then
                    .AddNew
                    !numero_client = num.Text
                    .Update
                    End If
                    End With
                    End Sub

                    and the standard module:

                    Option Explicit
                    Public db As DAO.Database
                    Public clt As DAO.Recordset

                    Sub main()
                    Set db = DBEngine.OpenDatabase("C:\****\****\Base de données.mdb")
                    Set clt = db.OpenRecordset("client")
                    End Sub

                    here is my email: gezaak@yahoo.fr
                    thanks
                    1. Hello,
                      I would like to create a program that would allow me to manage a school establishment, with an ACCESS database and VB6. how to proceed?
                      I admit I know nothing about VB6 except theoretical definitions.
                      if someone can help me, I would be very grateful. thank you.
                      1. Hello,
                        who can help me please regarding the connection between VB6 and Access?
                        I’m having trouble getting this to work...
                        it's very urgent please ...
                        1. I think that to display data in a grid or in the text boxes you should follow my example
                          the table being tall the chomsd (name, first name, code and datens)
                          1) in the module declare

                          Public DB As New ADODB.Connection
                          Public rs As New ADODB.Recordset

                          2) the form load

                          Set cn = New ADODB.Connection
                          Set DB = New ADODB.Connection
                          cn.Open "provider=Microsoft.jet.OLEDB.4.0; data source=C:\Documents and Settings\Nekor-bit bureau\Mes documents\fiche.mdb;Persist Security Info=False"

                          Private Sub Command1_Click()

                          If Text1.Text <> "" Then
                          On Error GoTo err
                          If IsNumeric(Text1) = False Then
                          Set DB = New ADODB.Connection
                          Set rs = New ADODB.Recordset
                          rs.CursorLocation = adUseServer 'may not be used
                          rs.CursorLocation = adUseClient 'very important Without this line, it generates an error 7004
                          DB.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Nekor-bit bureau\Mes documents\fiche.mdb;Persist Security Info=False"
                          rs.Open "select * from eleve where nom like '" & Text1.Text & "%'", DB, adOpenStatic, adLockOptimistic

                          Text2.Text = rs!code
                          Text3.Text = rs!nom
                          Text4.Text = rs!prenom
                          Text5.Text = rs!datens

                          Set Adodc1.Recordset.DataSource = rs
                          Set DataGrid1.DataSource = rs

                          Text1.SetFocus
                          End If
                          Set DataGrid1.DataSource = rs
                          err:
                          End If

                          bon courage

                          par essaouiqui
                        2. listen Jamal
                          with a data1 you can link the database to vb by the property database name and then at the bottom of the properties select the property recordsource

                          afterwards
                          the text boxes text1, texte2 etc you must link them by data source and datafields
                          thank you
                          by essaouiqui
                      2. Make sure first that your BD access is in the correct directory. Then declare a variable 'public con as ADODB.connection ds General'. Then try the connection instructions.
                        • 1
                        • 2
                        • 3