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. Connecting to remote (LAN) computer using UNC

Connecting to remote (LAN) computer using UNC

Scheduled Pinned Locked Moved C / C++ / MFC
sysadmindatabasehelptutorialquestion
7 Posts 2 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 Offline
    M Offline
    Mike the Red
    wrote on last edited by
    #1

    I have been scouring the web, msdn, and the help files trying to figure out how to do this, and have gotten nowhere except a web of abstract articles on Active Directories, and I'm not really sure A.D. is what I need to use to do this. :confused: Can someone please point me in the right direction? :confused: Thanks in advance for any help you can give. -Mike the Red Extra Details, just in case they're relevant: I'm using DAO to access a database on another computer on the network, which fails if the local machine does not already have an open connection to the server computer. I'm looking to check for the connection before opening the DAO object, and create the connection if it's not connected. I have serviceable, though not pretty, methods for checking the connection, but have no idea how to create it.)

    D 1 Reply Last reply
    0
    • M Mike the Red

      I have been scouring the web, msdn, and the help files trying to figure out how to do this, and have gotten nowhere except a web of abstract articles on Active Directories, and I'm not really sure A.D. is what I need to use to do this. :confused: Can someone please point me in the right direction? :confused: Thanks in advance for any help you can give. -Mike the Red Extra Details, just in case they're relevant: I'm using DAO to access a database on another computer on the network, which fails if the local machine does not already have an open connection to the server computer. I'm looking to check for the connection before opening the DAO object, and create the connection if it's not connected. I have serviceable, though not pretty, methods for checking the connection, but have no idea how to create it.)

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

      Mike the Red wrote:

      I'm using DAO to access a database on another computer...

      What does this code snippet look like?


      "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

      "We will be known forever by the tracks we leave." - Native American Proverb

      M 1 Reply Last reply
      0
      • D David Crow

        Mike the Red wrote:

        I'm using DAO to access a database on another computer...

        What does this code snippet look like?


        "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

        "We will be known forever by the tracks we leave." - Native American Proverb

        M Offline
        M Offline
        Mike the Red
        wrote on last edited by
        #3

        To simplify the process, this is the code snippet to open a DB that uses the default system database (usr/pass db).

        #include <afxdao.h>

        CDaoDatabase* daoDB = new CDaoDatabase();
        try {
        // Open Operational DB, shared, readonly
        daoDB->Open("\\\\Main\\E-Drive\\DB\\Operational.mdb", false, true);
        } catch (CDaoException * daoE) {
        // error handling code here
        return false; // unsuccessful
        } catch (Exception* e) {
        // error handling code here
        return false; // unsuccessful
        };
        // Open() method not throwing error doesn't necessarily mean DB has been opened
        //
        if (!daoDB->IsOpen()) {
        // Respond to DB open failure
        return false; // unsuccessful
        };

        Thanks again, Mike the Red

        D 1 Reply Last reply
        0
        • M Mike the Red

          To simplify the process, this is the code snippet to open a DB that uses the default system database (usr/pass db).

          #include <afxdao.h>

          CDaoDatabase* daoDB = new CDaoDatabase();
          try {
          // Open Operational DB, shared, readonly
          daoDB->Open("\\\\Main\\E-Drive\\DB\\Operational.mdb", false, true);
          } catch (CDaoException * daoE) {
          // error handling code here
          return false; // unsuccessful
          } catch (Exception* e) {
          // error handling code here
          return false; // unsuccessful
          };
          // Open() method not throwing error doesn't necessarily mean DB has been opened
          //
          if (!daoDB->IsOpen()) {
          // Respond to DB open failure
          return false; // unsuccessful
          };

          Thanks again, Mike the Red

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

          So what exception is thrown, or what error do you receive?


          "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

          "We will be known forever by the tracks we leave." - Native American Proverb

          M 1 Reply Last reply
          0
          • D David Crow

            So what exception is thrown, or what error do you receive?


            "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

            "We will be known forever by the tracks we leave." - Native American Proverb

            M Offline
            M Offline
            Mike the Red
            wrote on last edited by
            #5

            The daoDB->ReportError() method reports:

            The Microsoft Jet database engine cannot open the file '\\Main\E-Drive\DB\Operational.mdb'.
            It is already opened exclusively by another user, or you need permission to view its data.

            If, however, I open My Computer and type '\\Main\E-Drive\DB\' (or any valid path on \\Main) in the address bar, it prompts me to enter my user/pass, and then displays the contents of the drive/folder. After doing that, if I run the program again, I will no longer receive the error message and the DAO engine can access the file without issue. (It also works if I map a network drive to some share on \\Main .) My problem is that I can't seem to find a way to programatically connect to \\Main so that the share can be accessed.:wtf: -MZR

            D 1 Reply Last reply
            0
            • M Mike the Red

              The daoDB->ReportError() method reports:

              The Microsoft Jet database engine cannot open the file '\\Main\E-Drive\DB\Operational.mdb'.
              It is already opened exclusively by another user, or you need permission to view its data.

              If, however, I open My Computer and type '\\Main\E-Drive\DB\' (or any valid path on \\Main) in the address bar, it prompts me to enter my user/pass, and then displays the contents of the drive/folder. After doing that, if I run the program again, I will no longer receive the error message and the DAO engine can access the file without issue. (It also works if I map a network drive to some share on \\Main .) My problem is that I can't seem to find a way to programatically connect to \\Main so that the share can be accessed.:wtf: -MZR

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

              Would is be acceptable to call NetUseAdd() first to map a drive letter to \\Main\\E-Drive, and then use that drive letter in the call to Open()?


              "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

              "We will be known forever by the tracks we leave." - Native American Proverb

              M 1 Reply Last reply
              0
              • D David Crow

                Would is be acceptable to call NetUseAdd() first to map a drive letter to \\Main\\E-Drive, and then use that drive letter in the call to Open()?


                "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

                "We will be known forever by the tracks we leave." - Native American Proverb

                M Offline
                M Offline
                Mike the Red
                wrote on last edited by
                #7

                :-D I don't know how none of my searches turned that up, but thank you. I pulled up NetUseAdd in the help file, and the first thing (ok, second thing) it says is that you don't have to actually map the drive - you can use it to just authenticate with the server for future transactions. This should be perfect! Thanks, Mr. Crow - what a great help! :-D

                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