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. C / C++ / MFC
  4. Problem with ODBC connection

Problem with ODBC connection

Scheduled Pinned Locked Moved C / C++ / MFC
csharpdatabasevisual-studiohelpquestion
11 Posts 6 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.
  • J Offline
    J Offline
    Jackson86
    wrote on last edited by
    #1

    Hello. I'm trying to get connection to dBase file by using ODBC. I'm trying to use code like this: CDatabase cdb; cdb.OpenEx( _T("DBQ=F:\\database\\a.dbf;DefaultDir=F:\\database\\;DRIVER=Microsoft dBASE Driver (*.dbf);DriverId=533;MaxBufferSize=2048;PageTimeout=5;")); But i get message: string F:\database\a.dbf is an invalid path. But this file exactly exists!!! I'm using Visual Studio 2005. How should I solve the problem please?

    L M D D H 5 Replies Last reply
    0
    • J Jackson86

      Hello. I'm trying to get connection to dBase file by using ODBC. I'm trying to use code like this: CDatabase cdb; cdb.OpenEx( _T("DBQ=F:\\database\\a.dbf;DefaultDir=F:\\database\\;DRIVER=Microsoft dBASE Driver (*.dbf);DriverId=533;MaxBufferSize=2048;PageTimeout=5;")); But i get message: string F:\database\a.dbf is an invalid path. But this file exactly exists!!! I'm using Visual Studio 2005. How should I solve the problem please?

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      Create a DSN in the ODBC Data Source Administrator. That way you can create the connection settings and test it right there.

      led mike

      1 Reply Last reply
      0
      • J Jackson86

        Hello. I'm trying to get connection to dBase file by using ODBC. I'm trying to use code like this: CDatabase cdb; cdb.OpenEx( _T("DBQ=F:\\database\\a.dbf;DefaultDir=F:\\database\\;DRIVER=Microsoft dBASE Driver (*.dbf);DriverId=533;MaxBufferSize=2048;PageTimeout=5;")); But i get message: string F:\database\a.dbf is an invalid path. But this file exactly exists!!! I'm using Visual Studio 2005. How should I solve the problem please?

        M Offline
        M Offline
        Mark Salsbery
        wrote on last edited by
        #3

        It looks like the smiley-face-tongue-sticking-out may be the problem. Otherwise, what led mike said. Mark

        1 Reply Last reply
        0
        • J Jackson86

          Hello. I'm trying to get connection to dBase file by using ODBC. I'm trying to use code like this: CDatabase cdb; cdb.OpenEx( _T("DBQ=F:\\database\\a.dbf;DefaultDir=F:\\database\\;DRIVER=Microsoft dBASE Driver (*.dbf);DriverId=533;MaxBufferSize=2048;PageTimeout=5;")); But i get message: string F:\database\a.dbf is an invalid path. But this file exactly exists!!! I'm using Visual Studio 2005. How should I solve the problem please?

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          It's just a guess, but do you need to put ODBC; before DBQ?


          "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

          "Judge not by the eye but by the heart." - Native American Proverb

          1 Reply Last reply
          0
          • J Jackson86

            Hello. I'm trying to get connection to dBase file by using ODBC. I'm trying to use code like this: CDatabase cdb; cdb.OpenEx( _T("DBQ=F:\\database\\a.dbf;DefaultDir=F:\\database\\;DRIVER=Microsoft dBASE Driver (*.dbf);DriverId=533;MaxBufferSize=2048;PageTimeout=5;")); But i get message: string F:\database\a.dbf is an invalid path. But this file exactly exists!!! I'm using Visual Studio 2005. How should I solve the problem please?

            D Offline
            D Offline
            David Leyva
            wrote on last edited by
            #5

            Hi Only for test purposes try to change the location. I guess that file is in a network path. Regards David Leyva

            1 Reply Last reply
            0
            • J Jackson86

              Hello. I'm trying to get connection to dBase file by using ODBC. I'm trying to use code like this: CDatabase cdb; cdb.OpenEx( _T("DBQ=F:\\database\\a.dbf;DefaultDir=F:\\database\\;DRIVER=Microsoft dBASE Driver (*.dbf);DriverId=533;MaxBufferSize=2048;PageTimeout=5;")); But i get message: string F:\database\a.dbf is an invalid path. But this file exactly exists!!! I'm using Visual Studio 2005. How should I solve the problem please?

              H Offline
              H Offline
              Hamid Taebi
              wrote on last edited by
              #6

              did you create a DSN ?


              WhiteSky


              J 1 Reply Last reply
              0
              • H Hamid Taebi

                did you create a DSN ?


                WhiteSky


                J Offline
                J Offline
                Jackson86
                wrote on last edited by
                #7

                No. If I will create DSN, will my application run at the other computer?

                D 1 Reply Last reply
                0
                • J Jackson86

                  No. If I will create DSN, will my application run at the other computer?

                  D Offline
                  D Offline
                  David Crow
                  wrote on last edited by
                  #8

                  Jackson86 wrote:

                  ...the other computer?

                  What other computer?


                  "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

                  "Judge not by the eye but by the heart." - Native American Proverb

                  J 1 Reply Last reply
                  0
                  • D David Crow

                    Jackson86 wrote:

                    ...the other computer?

                    What other computer?


                    "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

                    "Judge not by the eye but by the heart." - Native American Proverb

                    J Offline
                    J Offline
                    Jackson86
                    wrote on last edited by
                    #9

                    I meant that, if i will create my DSN in ODBC Administrator in my computer, I sure that in another computer will be another DSN. Bu t I've already done with my problem. I got ODBC connection,using connection string. I understood my error. It's necessary after "DBQ=" in connection string to write path of folder, not of file.

                    D 1 Reply Last reply
                    0
                    • J Jackson86

                      I meant that, if i will create my DSN in ODBC Administrator in my computer, I sure that in another computer will be another DSN. Bu t I've already done with my problem. I got ODBC connection,using connection string. I understood my error. It's necessary after "DBQ=" in connection string to write path of folder, not of file.

                      D Offline
                      D Offline
                      David Crow
                      wrote on last edited by
                      #10

                      Jackson86 wrote:

                      It's necessary after "DBQ=" in connection string to write path of folder, not of file.

                      That must be a dBase thing. I used the following for a DSN-less connection to an Access database:

                      "ODBC;Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\\somefolder\\dataaccess\\ADO\\nwind.mdb;"


                      "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

                      "Judge not by the eye but by the heart." - Native American Proverb

                      J 1 Reply Last reply
                      0
                      • D David Crow

                        Jackson86 wrote:

                        It's necessary after "DBQ=" in connection string to write path of folder, not of file.

                        That must be a dBase thing. I used the following for a DSN-less connection to an Access database:

                        "ODBC;Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\\somefolder\\dataaccess\\ADO\\nwind.mdb;"


                        "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

                        "Judge not by the eye but by the heart." - Native American Proverb

                        J Offline
                        J Offline
                        Jackson86
                        wrote on last edited by
                        #11

                        Yes, you are right. It's dBase thing. But it was main problem for me. ODBC interprets dBase database as folder, where dbf files are located, and dbf files as tables of this database.

                        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