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