Solved

Database in LAN shared folder

Posted on 2004-10-14
13
378 Views
Last Modified: 2008-02-01
Hi,

I want to access another PC in the Same LAN where there is a Share Folder and a AccessDatabase inside it.

The problem is when I try to connect to that PC from my VB code as
\\192.168.2.10\Share\DB.mdb it gives runtime error -2147467259(80004005). It says that the path is not valid or I am not connected to the server.

But if I go to run and type \\192.168.2.10 and give the username/passwrd at prompt
and again run my VB it is working!!!!!!!!.

So the Moral of the story is how can I give the LAN Pc's username and password and also the username and password for the shared folder.

Thanking you,

Sujith.
0
Comment
Question by:esujithk
  • 3
  • 3
  • 2
  • +3
13 Comments
 
LVL 11

Expert Comment

by:dbrckovi
ID: 12306058
If it's a fixed network location you can map this shared folder as your local drive.

To achieve this, browse to shared folder, right click on it and select 'Map Network Drive...'

Now work with it as if it was on one of your local drives.
0
 
LVL 10

Expert Comment

by:anv
ID: 12306564
why dont u use RDO for this...??

check this
shows connectivity with MySQL u can change it to Access or any other db... u want to

http://www.vbmysql.com/samplecode/daomysql.html
0
 
LVL 5

Expert Comment

by:ZenMasterrr
ID: 12307014
try

\\computername\sharename\db.mdb

Zen :))
0
 
LVL 5

Expert Comment

by:ZenMasterrr
ID: 12307021
ahh wait, you have to give username PWD, then I suggest you go with dbrckovi

Zen :))
0
 
LVL 48

Expert Comment

by:Mikal613
ID: 12307404
use odbc and send the password and un toit.

also try mapped drives
0
 
LVL 76

Expert Comment

by:David Lee
ID: 12315406
By default connections use the security context of the current user.  If you're being prompted for an ID/password when you connect to this share, then your account doesn't have access.  So you must be using a different ID/password to access this share.  That gives us two possibilities: one, give your account the required permissions on this share; two, use RUNAS or some other form of impersonation and run the program under an account that has the necessary permissions.  One way to do this is to create a launcher program that does nothing more than shell out to the real program running it under the account that has permission to access the share.
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Author Comment

by:esujithk
ID: 12315846
Hi all, Thanks for ur Comments. But still I don't think anybody is answering my question. BlueDevilFan I think is  saying something but I am not able to understand him exactly.

Anyway, I would like to clarify once again. The question is I have my database in a PC2 in a folder share. I am a valid user of PC2. From PC1 if I try \\PC2\Share\MyDatabase.mdb in my VB Code then it will give message Database not found. Because I have not supplied the PC2's login/password and the Share folder's Login/password.

In one line --- How to supply the Username/password for PC2 and ShareFolder,      From my VB Code in PC1. So that that I can access the database in it.

Please write ur command in a Clear and Concise manner since I am a newbie.
0
 
LVL 10

Expert Comment

by:anv
ID: 12316019
0
 
LVL 76

Accepted Solution

by:
David Lee earned 210 total points
ID: 12316066
Let's see if I can explain this in a different way.  The account you are logged in under when you run the program must not have access to \\PC2\Share.  If it did, then you wouldn't get an error when you run the program and you wouldn't be prompted for a username and password when you type \\192.168.2.10, which I assume is the address for PC2, in the Run command box.  All of the commands you type and any programs you run while you are logged in run with with the same security restrictions that your account has.  So, if you don't have access, then any program you run won't have access either.  The restrictions and limitations of your account are what's known as a security context.  One obvious solution then is to give your account the right to access that location (\\PC2\Share or \\192.168.2.10).  If you're not an administrator, then you may not be able to change the rights your account has.  In that case see an administrator and ask them about increasing the rights for your account.  If this approach isn't doable, then there's a command called RUNAS that allows for running a program under a different account's security rights.  In other words you can be logged into the computer yet launch a program as if it was someone else who is logged in, someone who's account has access to \\PC2\Share.  This is called impersonation.  Using RUNAS you'd have two programs, the one that actually connects to the database, and a very small second program that launches the database program using the RUNAS command.  The database program would then be running as if it were the other account logged in, the one who's username/password you enter when you connect to \\192.168.2.10 from the Run command box.  Here's a link to a page that describes the RUNAS command: http://www.jsiinc.com/subf/tip2500/rh2548.htm

You want a one line answer to this and to the best of my knowledge there isn't one.  Some of the other experts have posted solutions that map a drive letter.  That's the simplest solution available.  The problem with it is that the drive letter is there the whole time the program is running and that means that the user, if it's not you, can do anything they want to the files in the mapped drive while the mapping exists.  I've participated in several questions that asked this same question.  Initially I proposed mapping a drive too, but found that most folks don't want that solution.  They are usually looking for a method that only allows the program to access the shared folder, not the user running the program.

I understand that you're a newbie and I'm trying to make my explanation as simple and straightforward.  I hope this helps.  If you are still confused, then please be specific on where the confusion is and I'll do my best to explain.
0
 

Author Comment

by:esujithk
ID: 12317193
I am verymuch thankful to Blue for having taken so much pain in helping me. But Blue, may be since I am a newbie, I not exactly getting you. Now from what I understood from you I will explain the scenario.

Suppose I have a Share folder in PC2 and user "Sujith" can has full (read write) access to it. User "Sujith" is not the administrator but a normal user in PC2. Also "Sujith" is a user in PC1. But the passwords for "Sujith" in PC1 and PC2 may be different.

Now user "Sujith" is running a VB code from PC1 to access the Share folder in PC2. The code used is \\PC2\Share\abc.mdb. This gives error that I had told earlier.

Now if I map \\Pc2\share in PC1 then on reboot it will ask for Password and then u get connected. But I don't wan't this since I don't want the PC1 user be aware of PC2 login. I wan't to keep the login information of PC2 in the code, so that VB code in PC1 will silently make the connection.

Thanks in Advance.
0
 
LVL 5

Expert Comment

by:ZenMasterrr
ID: 12317310
PC1 will only be aware of this connection if he monitors his shared folders in Computer management constantly

Zen :))
0
 

Author Comment

by:esujithk
ID: 12325695
There is no need for PC1 to continuously monitor whether it is connected to PC2 as Zen said.

I have my VB code in PC1 for which the database is in PC2. So when the code is run it will search for the database and then it will make connection with PC2 and then access the database(db.mdb).

what I want is simple HOW TO LOGON TO PC2 FROM MY PC1 VBCODE.
I hope the question is clear.
I thank all experts for the comments.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now