Visual Basic and Access database

salima -  
 jamal_ho -
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
  • 2
  • 3
  1. antonyojunior Posted messages 22 Status Member 42
     
    How to establish a connection between VB6.0 and an Access database?
    44
    1. gaetan
       
      YES I’d really like that a lot please!
      0
    2. maestro
       
      I have an Access 2003 database that I want to connect to an EXE program. Standard VB6
      0
  2. meryem01
     
    Hi, I just read this forum but I still can't link my Access database with VB6. I have a database made up of 4 tables and some queries. I want, using VB, to display some fields from the table, modify them, delete and add records, insert statistics already calculated by the Access queries... thank you for any help and I would like you to send me courses that you consider interesting. Thanks for everything
    15
  3. leonelrichie Posted messages 1 Status Member 7
     
    Hi, if possible I’d like to have effective courses with examples on databases created with VB6 and Access.
    7
  4. Vignon
     
    Hello,
    I’m developing a VB6 application on a Windows 2000 platform that is specific to a company, and I can’t connect to the Access 2000 database I created. It tells me it doesn’t recognize the database format. I’ve tried with other codes but nothing works. Can you help me?
    Here is the message “Connection failed, please try again”
    I’m sending you the code I used:

    Option Explicit
    'Global variable declarations
    'Global DbName As String
    Global Liberreur As String
    'Global OK As Integer

    Public Cnx As New ADODB.Connection
    Public Rst As New ADODB.Recordset
    Public Cmd As New ADODB.Command
    Sub main()
    'This procedure calls the function to open the DB and shows the home window.
    If OuvrirBase = True Then
    frmConnexion.Show
    Else
    MsgBox ("La connexion n'a pas réussi,réessayez")
    End If
    End Sub

    Public Function OuvrirBase() As Boolean
    'This function opens the Access 2000 DB
    On Error GoTo Erreur

    Cnx.Provider = "Microsoft.Jet.Oledb.4.0"
    Cnx.ConnectionString = App.Path & "c:\db1.mdb"
    Cnx.Open
    Cmd.ActiveConnection = Cnx
    OuvrirBase = True
    Exit Function
    '\\gbemich\\GESPARC\\Application\\
    Erreur:
    Liberreur = "Erreur d'ouverture de la Base"
    OuvrirBase = False
    End Function

    Public Sub OuvrirRecord(StrSQL As String)
    'This procedure opens all tables of the DB. This code means to open a table, you must pass a SQL query, i.e. a ''select''
    'Look in the help for these properties to see what they do

    Cmd.ActiveConnection = Cnx
    Cmd.CommandText = StrSQL
    Rst.CursorLocation = adUseClient
    Rst.CursorType = adOpenDynamic
    Rst.LockType = adLockPessimistic
    Rst.Open Cmd
    End Sub

    Public Sub FermerRecord()
    'This procedure closes all tables of the DB
    On Error Resume Next
    Rst.Close
    Set Rst = Nothing
    Set Rst = New ADODB.Recordset
    End Sub

    Public Sub FermerBase()
    'This procedure closes the DB
    On Error Resume Next
    Cnx.Close
    Set Cnx = Nothing
    End Sub
    4
    1. KAFILONGO
       
      You can also convert the database to a lower version, i.e., to version 97. And everything will be better.
      0
    2. Furankuku
       
      Hello Vignon, I don’t know if you’ve found the solution, but I think the BD path isn’t correct. Try instead: Cnx.ConnectionString = App.Path & "\\db1.mdb" because App.Path probably designates the path to db1.mdb and "\" is a special character Finally, to be seen / to check.
      0
    3. Dhellatres
       
      If you can’t connect to the database, it’s because you’ve concerted the database to version 2000

      you must concert the database to version 97
      and then it will work.

      C all
      0
    4. MIMO
       
      YOU MUST CONVERT YOUR DATABASE TO 97 FORMAT
      UNDER ACCESS
      STEPS:
      CLICK ON TOOLS MENU
      DATABASE UTILITIES
      CONVERT DATABASE TO 97 FORMAT
      you give the file a name
      in this case you will have 2 databases
      * 2000 format
      * format 97

      in vb:
      DATA properties

      DATABASENAME: connect to the database format 97 because the DATA control does not recognize the 2000 format
      0
  5. isgt Posted messages 46 Status Member 3
     
    Hello everyone
    how can I display an image on the entire form in VB
    because when I do it it doesn't display on the form, part of it remains
    3
  6. ANDO
     
    Contact me at ghost_dog_jr@hotmail.com and I will give you a tutorial, and tips if you want, because it's a bit long to explain...
    2
    1. salima
       
      Hi Ando, it's very kind of you to have replied to me
      0
    2. dithy
       
      Hello, please. I’m a beginner in programming. I created a database in Access and since I have no knowledge of VB I can’t get my database to work, so I’m coming to you so you can help me.
      0
    3. sawssana
       
      Hello, I’m Salima Lakhal, I have a problem understanding Access and I’d like to help you assist me (to help me please) ok my MSN safae_roubi@hotmail.fr contact me at this email I want you to help me please friends help me
      0
    4. nyinawumuntu olive
       
      Hi, I’m Olive. I have a problem understanding how to create Visual Basic and a database, and why Access 2007 is very complicated. Can you give me the solution, please? Thank you.
      0
    5. un rageux
       
      poor screw-up, you can't write in a post to respond to the community. If he doesn't know, there are others... that's how we end up with unresolved problems.

      too long to write? it will be longer to explain it to every person who asks you for it
      0
  7. Abdou
     
    Ok Salima, first of all, when you open VB under the Project menu -> References -> check Microsoft DAO 2.5/3.51 compatibility library.

    Then in the programming editor, type the following lines of code:

    dim cnx as adodb.connection
    dim cmd as adodb.command
    dim rs as adodb.recordset

    under the form_load() procedure, type:

    set cnx=new adodb.connection
    set cmd=new adodb.command
    set rs=new adodb.recordset

    cnx.Provider="Microsoft.jet.oledb.4.0"
    cnx.connectionstring="your database that must be in the project folder.mdb"
    rs.cursorlocation=adUseClient
    rs.cursortype=adopenDynamic
    rs.locktype=adlockPessimistic

    rs.open cmd

    I wish you good luck and stay strong

    Best regards
    2
    1. Alain
       
      I see that you master Access 2007, can you give me the solution to convert an Access 97 database to Access 2003 without any problem. I have tried all possible and unimaginable methods and .... still nothing.
      0
  8. srigovich
     
    Hello

    If you have the program that connects VB with Access, could you post it to: srigovich@hotmail.com
    Thanks in advance
    2
  9. ti pimous
     
    Hi,

    To avoid some crashes, you need to convert your database to ACCESS 97.

    Run a test to see.

    See you later
    1
  10. salima
     
    First of all I thank you for your response, it’s very kind of you, and this solution, I’ve already tried it and it works, but the Office installed on the machines is version 2000, so I still can’t convert every time, that’s not professional, and I don’t understand why Office 2000 is less performant than version 97.
    1
    1. majid
       
      Majid's reply to Salima:
      it's not that Office 2000 is less performant than Office 97; it's the opposite. The problem is that the Data control in Visual Basic doesn't know Access 2000 databases, so to solve the problem use the ADODC control. The problem will be resolved.
      0
  11. moh
     
    I usually work with VB and Access, send me your code to see

    *you put a DATA control
    *a DBGRID
    or not
    example

    you declare it as follows
    SET MO (the name of the variable you will work with) as Database = "the path to your database"
    SET moo as Database.Recordset = "the name of the table"
    1
    1. MOUMEN RAHAL
       
      THANK YOU VERY MUCH I AM A BEGINNER IN VB AND I CREATED A SMALL PROJECT OF CIVIL SERVANTS IN WHICH THERE ARE ALL THE INFORMATIONS NAME FIRST NAME ETC... WITH THE PHOTO FOR WHICH I FOUND THE PROBLEM AT THE MOMENT OF THE JOIN OF A NEW RECORD IT IS FOR THIS REASON I ASK YOU TO HELP ME FIND HOW TO INSERT AN IMAGE USING A BUTTON ADD AN IMAGE THANK YOU A SECOND TIME MOUMEN RAHAL
      0
  12. 123456
     
    I want to know how I can link VB 6.0 with the database of NES
    nes I
    1
  13. hackmed
     
    You need to create an Access 97 database base for VB6.
    1
  14. salima
     
    Hello Moh
    In Visual Basic I linked my program to the Access 2000 database via the Data control, but it reports a database access error, which is really surprising since it works very well with Access 97, I don’t understand anymore, I hope you can help me, I’m counting on you
    See you soon on the net
    0
    1. moh
       
      Do you need to display all the contents of the database or do you want to work with it (perform a search)?
      I got the same problem with Access 2000 I think there's an incompatibility with Access 2000
      but I'll see how to proceed
      0
    2. mbarek
       
      Hello Salima the solution to your problem is to use the ADO model to link the Microsoft Access 2000 or later database with Visual Basic, but to link Access 97 database use the DAO model (Data)
      0
      1. zayed > mbarek
         
        Hello
        I’ve found a problem similar to the one proposed by Salima. But the issue is choosing the right references to include. dear friend, do you know which references to add in order to be able to use ADO.
        0
  15. Merzak
     
    sorry but the data must be changed it is incompatible with Access2000
    and if you want more explanation about the problem you can contact me at my email address to get more details about your problem, A+
    0
  16. ngo Posted messages 1 Registration date   Status Member
     
    hi everyone,
    I would like to know some basic functions that would allow me to manipulate an Access 2003 database with Visual C.
    well, thanks to all who will help us^^
    see you soon.
    0
  17. samiha
     
    you need to convert your database to Access 97 format; for that, in Access go to Tools, Database Utilities, then perform the conversion and attach it to the VB project. good luck
    0
    1. kamilio
       
      Hi, I’m sending you some courses to learn how to connect the database to my code B6, my MSN: tel_kamal@hotmail.fr, and thanks for your help. I’m waiting for your reply. Kamal B
      0
  18. username
     
    you are looking for the ocx data object 3.6 instead of 3.5 that Office 2000 requires
    0
  19. mokhtar
     
    listen I don’t know how to tell you this well explain your problem clearly I have always worked with VB and Access databases so if you want help shed some light on your problem
    0
  20. hanshans26
     
    hi Salma
    to be able to connect to a Access 2000 database you must use the Microsoft DAO 3.6 OCX:
    in the Project menu click on the References tab and try to find it in the list of checkboxes
    if you don't find it try to search using Windows search utility to know its path, then come back to your References tab and click Browse to locate your OCX and add it. good luck
    my email: hanshans26@hotmail.com
    in case you want to tell me something because I only connect rarely
    0
    1. kozan
       
      I'm really struggling,
      For two days I’m not making progress on my project: I have a problem with boolean variables. When I add a member, there’s no issue: it stores correctly in the database, but for data I entered myself from Access, I can’t get it to appear in the button options. I’ve tried True/False, yes/no, -1/0, false/true... please help me!!!!!!!!!!!!!!!!
      0
  • 1
  • 2
  • 3