Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. open mdb file

open mdb file

Scheduled Pinned Locked Moved Visual Basic
databasehelpquestion
14 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M meirav

    help me!!!!

    C Offline
    C Offline
    Cliff Wellman
    wrote on last edited by
    #5

    As RageInTheMachine9532 said, a code sample would help us help you. Right now we don't have enough information.

    M 1 Reply Last reply
    0
    • C Cliff Wellman

      As RageInTheMachine9532 said, a code sample would help us help you. Right now we don't have enough information.

      M Offline
      M Offline
      meirav
      wrote on last edited by
      #6

      set db as database set rec as recordset open db=opendatabase("xx.mdb") open rec=db.openrecordset("select * from xx",opendynaset) I GOT ERROR AT LINE NUMBER 3

      C 1 Reply Last reply
      0
      • M meirav

        set db as database set rec as recordset open db=opendatabase("xx.mdb") open rec=db.openrecordset("select * from xx",opendynaset) I GOT ERROR AT LINE NUMBER 3

        C Offline
        C Offline
        Cliff Wellman
        wrote on last edited by
        #7

        Well the syntax of your example is not correct but I think I know what you're trying to do. The first thing that I'd do is try using the absolute path of the database and see if that works. Here is an example of the same code that I tried that worked. Dim db As Database Dim rs As Recordset ' open the database in the application directory Set db = OpenDatabase(App.Path & "\mydata.mdb") Set rs = db.OpenRecordset("SELECT * FROM MYTABLE") The only other thing that I'd recommend is that you use ADO vs. DAO.

        M 1 Reply Last reply
        0
        • C Cliff Wellman

          Well the syntax of your example is not correct but I think I know what you're trying to do. The first thing that I'd do is try using the absolute path of the database and see if that works. Here is an example of the same code that I tried that worked. Dim db As Database Dim rs As Recordset ' open the database in the application directory Set db = OpenDatabase(App.Path & "\mydata.mdb") Set rs = db.OpenRecordset("SELECT * FROM MYTABLE") The only other thing that I'd recommend is that you use ADO vs. DAO.

          M Offline
          M Offline
          meirav
          wrote on last edited by
          #8

          i tried to do it but i get the same massege any connection to the projet refrenses, i choose(microsoft dao 3.6)?

          C D 2 Replies Last reply
          0
          • M meirav

            i tried to do it but i get the same massege any connection to the projet refrenses, i choose(microsoft dao 3.6)?

            C Offline
            C Offline
            Cliff Wellman
            wrote on last edited by
            #9

            In Project References try using: "Microsoft ActiveX Database Object 2.7 Library." If you don't have the 2.7 library, you should have either 2.0, 2.1, 2.5, or 2.6. Use one of them. I was looking in the VB documentation and for DAO it says that the OpenDatabase statement is depricated and that you should use the DBEngine object to open a database. So if you must use DAO, then try checking out the documentation on the DBEngine object. By the way, I was able to use DAO to access my database. So maybe you have some other configuration problem.

            M 1 Reply Last reply
            0
            • M meirav

              i tried to do it but i get the same massege any connection to the projet refrenses, i choose(microsoft dao 3.6)?

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #10

              Then you might want to try hard coding the entire path to the database in your OpenDatabase statement because it looks like OpenDatabase can't find your filename in the default path or the path your project is running from.

              Dim db As Database
              Dim rs As Recordset

              ' open the database from exactly where I say it is
              Set db = OpenDatabase("C:\FullPath\ToMyDatabase\mydata.mdb")
              Set rs = db.OpenRecordset("SELECT * FROM MYTABLE")

              and SERIOUSLY consider moving your code to ADO instead of DAO. DAO seems to be a dead technology. If your using VB6, you can start here[^] to learn about ADO. If your using VB.NET, you might want to start here[^]. RageInTheMachine9532

              1 Reply Last reply
              0
              • C Cliff Wellman

                In Project References try using: "Microsoft ActiveX Database Object 2.7 Library." If you don't have the 2.7 library, you should have either 2.0, 2.1, 2.5, or 2.6. Use one of them. I was looking in the VB documentation and for DAO it says that the OpenDatabase statement is depricated and that you should use the DBEngine object to open a database. So if you must use DAO, then try checking out the documentation on the DBEngine object. By the way, I was able to use DAO to access my database. So maybe you have some other configuration problem.

                M Offline
                M Offline
                meirav
                wrote on last edited by
                #11

                I am using access 2003. is there any special configuration for this version that you know about that i should try?

                C 1 Reply Last reply
                0
                • M meirav

                  I am using access 2003. is there any special configuration for this version that you know about that i should try?

                  C Offline
                  C Offline
                  Cliff Wellman
                  wrote on last edited by
                  #12

                  Are you getting an error number? I tried to open a file that didn't exist and I got a run time erro #3024. Is that what you get? Or do you get some other number error number? Regarding Access 2003, I'm not aware of any configuration stuff that would affect a VB program.

                  M 1 Reply Last reply
                  0
                  • C Cliff Wellman

                    Are you getting an error number? I tried to open a file that didn't exist and I got a run time erro #3024. Is that what you get? Or do you get some other number error number? Regarding Access 2003, I'm not aware of any configuration stuff that would affect a VB program.

                    M Offline
                    M Offline
                    meirav
                    wrote on last edited by
                    #13

                    Yes, this is the error number i get. but the exist.

                    C 1 Reply Last reply
                    0
                    • M meirav

                      Yes, this is the error number i get. but the exist.

                      C Offline
                      C Offline
                      Cliff Wellman
                      wrote on last edited by
                      #14

                      I'm grasping at straws...but have you tried opening up another database file. Maybe create a database with one table and try to access that. OR Maybe it's a sharing violation. In the past I've had trouble opening a database if I had it open in MS-Access, especially if it's open exclusively by MS-Access.

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups