473,939 Members | 10,203 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Entering a Username & Password within a Function

4 New Member
Hi there,

I want to open a database from a macro in another database and I have it working, except that we have usernames and passwords to log on, so when the macro is run is automatically asks for a username and password.

I've tried entering the conditions as follows:

'Open the External Database in Access Window
appAccess.OpenC urrentDatabase strDBPath, False, bstrPassword

providing it with the database path (as String), that I don't need to enter the database exclusively, and finally providing it with my password (as String). However, it doesn't pick up the password. However, once I key it in manually, it will continue running correctly till completion.

I would appreciate if somebody could let me know is it possible to automate this, so that I could open the database etc. without having to manually enter the password?

Thanks in advance.
Aug 2 '07 #1
8 3818
ADezii
8,834 Recognized Expert Expert
Hi there,

I want to open a database from a macro in another database and I have it working, except that we have usernames and passwords to log on, so when the macro is run is automatically asks for a username and password.

I've tried entering the conditions as follows:

'Open the External Database in Access Window
appAccess.OpenC urrentDatabase strDBPath, False, bstrPassword

providing it with the database path (as String), that I don't need to enter the database exclusively, and finally providing it with my password (as String). However, it doesn't pick up the password. However, once I key it in manually, it will continue running correctly till completion.

I would appreciate if somebody could let me know is it possible to automate this, so that I could open the database etc. without having to manually enter the password?

Thanks in advance.
The Password that you are referring to is the Database Password, not the Password associated with the UserName/Password combination seen in Access security Models. That is why entering it as an Argument in the OpenCurrentData base() Method had no effect.
Aug 2 '07 #2
BJByrne
4 New Member
Thanks for this. However, I still would appreciate if somebody could let me know if it's possible to automatically override the username and password of the database I am opening, or to code the username and password, so the function can be run automatically?

Thanks.
Aug 14 '07 #3
ADezii
8,834 Recognized Expert Expert
Thanks for this. However, I still would appreciate if somebody could let me know if it's possible to automatically override the username and password of the database I am opening, or to code the username and password, so the function can be run automatically?

Thanks.
There are several Methods of automating the process of entering a Database's Password but the User Name and Password is another problem. You could try SendKeys by placing certain Keystrokes in the buffer, then inserting them at the proper time, but this would be a little hairy to say the least. I'll look into it further for you.
Aug 14 '07 #4
Lysander
344 Recognized Expert Contributor
There are several Methods of automating the process of entering a Database's Password but the User Name and Password is another problem. You could try SendKeys by placing certain Keystrokes in the buffer, then inserting them at the proper time, but this would be a little hairy to say the least. I'll look into it further for you.
If both databases are using the same MDW and you are moving from one to the other with the same username, you should not need to specify passwords as you are already logged on to the MDW


If you are using different MDW's or different usernames and passwords you could try looking at the help for
Expand|Select|Wrap|Line Numbers
  1. DBEngine.OpenDatabase
because I see that lets you specify connect info such as MDW, username, password.
I use DBEngine.Create Workspace a lot to change to a hidden secure user for certain functions, and I think the OpenDatabase method is the way to go.

I can't be more help as I have not needed to do this myself.
Aug 14 '07 #5
ADezii
8,834 Recognized Expert Expert
If both databases are using the same MDW and you are moving from one to the other with the same username, you should not need to specify passwords as you are already logged on to the MDW


If you are using different MDW's or different usernames and passwords you could try looking at the help for
Expand|Select|Wrap|Line Numbers
  1. DBEngine.OpenDatabase
because I see that lets you specify connect info such as MDW, username, password.
I use DBEngine.Create Workspace a lot to change to a hidden secure user for certain functions, and I think the OpenDatabase method is the way to go.

I can't be more help as I have not needed to do this myself.
I think I found one solution to your dilemma, and it involves specifying the User ID and Passwords as properties of the ADODB Connection Object. The following code will open the Test.mdb Database in the C:\Test Directory, then loop through all Records in tblEmployees printing the First and Last Names. I've tested it on an Unsecured Database and it works fine. Make the necessary substitutions, and attempt to open your External, Secured, Database and see what happens. Please get back to me on this one, I'm curious myself as to the outcome. Good Luck!
Expand|Select|Wrap|Line Numbers
  1. Dim cnn As ADODB.Connection
  2. Dim rst As ADODB.Recordset, strPathToExternalDB As String
  3.  
  4. strPathToExternalDB = "C:\Test\Test.mdb"
  5.  
  6. Set cnn = New ADODB.Connection
  7. Set rst = New ADODB.Recordset
  8.  
  9. cnn.Provider = "Microsoft Jet 4.0 OLE DB Provider"
  10. cnn.ConnectionString = "Data Source = " & strPathToExternalDB
  11. cnn.Properties("User ID").Value = "Admin"       'unsecured database
  12. cnn.Properties("Password").Value = ""           'unsecured database
  13.   cnn.Open
  14.  
  15. With rst
  16.   .Source = "tblEmployees"
  17.   .ActiveConnection = cnn
  18.   .CursorType = adOpenKeyset
  19.   .LockType = adLockOptimistic
  20.     .Open
  21. End With
  22.  
  23. rst.MoveFirst
  24. Do While Not rst.EOF
  25.   'do whatever processing you need to do here
  26.   Debug.Print rst![FirstName] & " " & rst![LastName]
  27.     rst.MoveNext
  28. Loop
  29.  
  30. rst.Close
  31. cnn.Close
  32. Set rst = Nothing
  33. Set cnn = Nothing
  34.  
Aug 14 '07 #6
BJByrne
4 New Member
Hi there,

Well after much playing around, I'm afraid I cannot get passed the error message at cnn.open:

Run-time Error ....
Cannot Start your application. The workgroup information file is missing or opened exclusively by another user.

But thanks a million for all your help with this matter, it's much appreciated and if you do have any other suggestions let me know.

Thanks.
Aug 23 '07 #7
ADezii
8,834 Recognized Expert Expert
Hi there,

Well after much playing around, I'm afraid I cannot get passed the error message at cnn.open:

Run-time Error ....
Cannot Start your application. The workgroup information file is missing or opened exclusively by another user.

But thanks a million for all your help with this matter, it's much appreciated and if you do have any other suggestions let me know.

Thanks.
Cannot understand why you getting this Error Message if the Database is not opened Exclusively by another User. When I get the chance, I'll try the code on a secured Database.
Aug 24 '07 #8
ADezii
8,834 Recognized Expert Expert
Hi there,

Well after much playing around, I'm afraid I cannot get passed the error message at cnn.open:

Run-time Error ....
Cannot Start your application. The workgroup information file is missing or opened exclusively by another user.

But thanks a million for all your help with this matter, it's much appreciated and if you do have any other suggestions let me know.

Thanks.
I am happy to report that I finally solved the problem. You must explicitly specify the location of the System Database in the "Jet OLEDB:System database" Property of the Connection Object (just add Line #14). The following code will Open the Northwind.mdb Database in the C:\Dell\ Directory using the C:\Dell\ADH.MDW System Database. The User ID and Password are programmaticall y supplied. Good luck - any other questions feel free to ask. I going to relax now, since this one really taxed my brain:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command7_Click()
  2. Dim cnn As ADODB.Connection
  3. Dim rst As ADODB.Recordset, strPathToExternalDB As String
  4.  
  5. strPathToExternalDB = "C:\Dell\Northwind.mdb"
  6.  
  7. Set cnn = New ADODB.Connection
  8. Set rst = New ADODB.Recordset
  9.  
  10. cnn.Provider = "Microsoft Jet 4.0 OLE DB Provider"
  11. cnn.ConnectionString = "Data Source = " & strPathToExternalDB
  12. cnn.Properties("User ID").Value = "Paul"       'secured database
  13. cnn.Properties("Password").Value = "Paul"      'secured database
  14. cnn.Properties("Jet OLEDB:System database") = "C:\Dell\ADH.MDW"
  15.   cnn.Open
  16.  
  17. With rst
  18.   .Source = "Employees"
  19.   .ActiveConnection = cnn
  20.   .CursorType = adOpenKeyset
  21.   .LockType = adLockOptimistic
  22.     .Open
  23. End With
  24.  
  25. rst.MoveFirst
  26. Do While Not rst.EOF
  27.   'do whatever processing you need to do here
  28.   Debug.Print rst![FirstName] & " " & rst![LastName]
  29.     rst.MoveNext
  30. Loop
  31.  
  32. rst.Close
  33. cnn.Close
  34. Set rst = Nothing
  35. Set cnn = Nothing
  36. End Sub
  37.  
Aug 25 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

4
6091
by: Lobang Trader | last post by:
Hi all, I am trying to create a username and a password class. I would like to know what are the RECOMMENDED minimum and maximum length for both fields? These fields will be something like this: private static final int DEFAULT_MINIMUM_LENGTH = ??????
3
2773
by: Matt | last post by:
Hiya I have to develop a web application for my company in which I need to have a facility for username and password for the employees to do certain tasks. How can this be implemented in ASP. I am thinking of having usernames and passwards (encrypted) in database and when a person tries to log in, the script will compare those stored in databse to the values entered by user. But after the user has logged in, how can I make sure that the...
11
13988
by: Kevin O'Brien | last post by:
Hello, I am creating a sign on screen for my application in which I want to store the username and password in a database table. I was thinking of putting a combo box connected to the database to pull up the usernames and then having a textbox for the user to enter their password. Can someone tell me please how to compare the contents of the textbox to the password in the database?
1
1652
by: gujarsachin2001 | last post by:
hello friends i m connecting to http or https url programatically through console application using follwoing methods of credentilas but if there is username & password for that url through this code I m able to download files from that url using "DefaultCredentials" but i want to use password and username to access resources if tht url contains. & if for tht specific url if user enters wrong username & password so tht he must not...
5
12068
by: Hooyoo | last post by:
Hi, here. I write following codes: string password = Console.ReadLine(); I want users enter their passwords, but readline will show content of password when entering, so is there any way to show star(*) when entering?
0
3008
by: sanbm79 | last post by:
Hi All, I am facing a problem in posting Web request with username and password credentials. I am working on migrating Java client application to .Net which will send request to Java servlet. Java Client application code: HttpClient httpclient; httpclient = new HttpClient();
5
3789
by: libra786 | last post by:
I have created a blog and have added a login box which prompts the user for login and id before posting- The username and password have been stored in the database, however when i enter the username and pasword it does not seem to compare the values entered with anything. It jus keeps giving the prompt box to enter details. But if i click cancel, then it tels me the incorrect credentials ave been entered i have tried many ways to solve this...
3
1465
by: patelxxx | last post by:
Guy's, I'm using the following code and before I even enter my username and password I get the following error: 'Username or password did not match', what I'm I doing wrong? my $session = VM::Generic->new(); my $input = $session->parse_input; my $templateprefix = $input->{'area'} || 'reporting'; $session->validate_session($input);
3
19660
by: rodrigo | last post by:
I am trying to retrieve a password protected page using: get = urllib.urlopen('http://password.protected.url"').read() While doing this interactively, I'm asked for the username, then the password at the terminal. Is there any way to do this non-interactively? To hardcode the user/ pass into the script so I can get the page automatically? (This is not a cracking attempt, I am trying to retrieve a page I have
0
10134
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11525
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11110
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
11293
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10659
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8218
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6077
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4908
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4447
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.