Solved

Accessing an access database with a password

Posted on 2003-11-11
26
245 Views
Last Modified: 2012-05-04
MyDB.ConnectionString = _
        "Provider=Microsoft.Jet.OLEDB.4.0;" & _
        "Data Source=" & App.Path & "\sys.ald" & ";UserName=Admin;PASSWORD=Password" & _
        "Persist Security Info=False"

What have I done wrong?

   - Marc
0
Comment
Question by:MarcGraff
  • 12
  • 5
  • 4
  • +2
26 Comments
 
LVL 28

Expert Comment

by:vinnyd79
ID: 9726845
try:

MyDB.ConnectionString  = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source= " & App.Path & "\sys.mdb;" & "Jet OLEDB:Database Password=myPassword;"
0
 
LVL 18

Expert Comment

by:Sethi
ID: 9726859
Use this:
MyDB.ConnectionString = _
        "Provider=Microsoft.Jet.OLEDB.4.0;" & _
        "Data Source=" & App.Path & "\sys.ald" & ";UserName=Admin;Jet OLEDB:Database Password=Password" & _
        "Persist Security Info=False"
Also look at the following sites if you further need help with connection strings:

http://www.connectionstrings.com
http://www.able-consulting.com/ADO_Conn.htm
0
 
LVL 1

Author Comment

by:MarcGraff
ID: 9727115
Error: -2147467259 Could not find installable ISAM.

I have never had that one before... :)


   - Marc
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 9727151
You should be using atleast MDAC 2.5
0
 
LVL 1

Author Comment

by:MarcGraff
ID: 9727201
MDAC 2.5?

   - Marc
0
 
LVL 1

Author Comment

by:MarcGraff
ID: 9727208
Microsoft Data Access Components?

   - Marc
0
 
LVL 1

Author Comment

by:MarcGraff
ID: 9727218
I am using v3.52 if you are referring to Microsoft Data Access Components
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 9727247
Do you want to use DAO rather than ADO? The above example should work if you refence Microsoft ActiveX Data Objects Library 2.X
0
 
LVL 1

Author Comment

by:MarcGraff
ID: 9727315
I do have ActiveX Data Objects Library 2.0 refrenced. DAO or ADO? It doesn't matter as long as it works.

I does work if I remove the password from the file.

   - Marc
0
 
LVL 28

Assisted Solution

by:vinnyd79
vinnyd79 earned 100 total points
ID: 9727454
2.0 is old. I would recommend using atleast 2.5 or higher.

http://www.microsoft.com/downloads/details.aspx?FamilyID=83e8f178-94c9-4e7d-b0b6-a8a94c4eb912&DisplayLang=en

I tend to use version 2.5 for compatability reasons but I do have 2.6 and 2.7 installed on my development machine.
0
 
LVL 1

Author Comment

by:MarcGraff
ID: 9727653
Using ActiveX v2.7, go the same "Error: -2147467259 Could not find installable ISAM."

:(

   - Marc
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 9727847
Is it an access97 database?
0
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.

 
LVL 14

Expert Comment

by:Farzad Akbarnejad
ID: 9728219
Hello
Try to use DAO. Use Workspace object in DAO to setup password then use wks.opendatabase method.

-FA
0
 
LVL 7

Assisted Solution

by:_agj_
_agj_ earned 200 total points
ID: 9728364
in ado use:

    Dim conn As ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim strSELECT As String
   
    Set conn = CreateObject("ADODB.Connection")
   
With conn
        .Provider = "MSDASQL"
        .ConnectionString = "ODBC" _
                            & ";DATABASE=" _
                            & ";UID=" _
                            & ";PWD=mypass" _
                            & ";DSN=" & "Sample DSN"
                           
        .Open
End With

in dao use:

Dim sConnect As String
Dim sDatabaseName As String
Dim dbTemp As DAO.Database

sConnect = ";pwd=" & "mypass"
sDatabaseName = "c:\mydir\mydatabase.mdb"
Set dbTemp = Workspaces(0).OpenDatabase(sDatabaseName, False, False, sConnect)
0
 
LVL 18

Accepted Solution

by:
Sethi earned 200 total points
ID: 9728429
The problem lies in your connection string:

MyDB.ConnectionString = _
        "Provider=Microsoft.Jet.OLEDB.4.0;" & _
        "Data Source=" & App.Path & "\sys.ald" & ";UserName=Admin;Jet OLEDB:Database Password=Password" & _
        "Persist Security Info=False"



You are passing "sys.ald" as data source and using Access OleDB providers. The extension for Access database is "mdb". So it should be "sys.mdb".
0
 
LVL 1

Author Comment

by:MarcGraff
ID: 9732909
The database is an access 2000 DB. I would like to use ado.

_agj_,
It came back with: "Error:-2147467259 [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified"
and when I added & ";Data Source=" & App.Path & "\sys.dat" _ it said:
Error:-2147467259 [Microsoft][ODBC Driver Manager] Data source name too long

   - Marc
0
 
LVL 18

Expert Comment

by:Sethi
ID: 9736397
That's what I said. The file extension of Access database is mdb and you are passing wrong file extension. It should be ".mdb" for it to work properly.
0
 
LVL 7

Expert Comment

by:_agj_
ID: 9737169
hey....u got the error trying ADO, did u?
hav u set up the DSN properly usign the thing in the control panel?
if so, u jus need the DSN name, no need of the datasource name.
0
 
LVL 1

Author Comment

by:MarcGraff
ID: 9740400
Sethi:
I changed the extention of the file and in the code and it does not make a diffrence.

_agj_:
I am not using ODBC Data Source Administrator. I can not do this because this will run on a network.


If I remove the Database Password through access this code will work:
    MyDB.ConnectionString = _
        "Provider=Microsoft.Jet.OLEDB.4.0;" & _
        "Data Source=" & App.Path & "\sys.dat" & ";" & _
        "Persist Security Info=False"

   - Marc
0
 
LVL 7

Assisted Solution

by:_agj_
_agj_ earned 200 total points
ID: 9745260
the passwrd string isnt Password=
it is:

                           & ";PWD=mypass" _
0
 
LVL 1

Author Comment

by:MarcGraff
ID: 9748137
Same thing:


    MyDB.ConnectionString = _
        "Provider=Microsoft.Jet.OLEDB.4.0;" & _
        "Data Source=" & App.Path & "\sys.dat" & ";" & _
        "PWD=mypass;" & _  
        "Persist Security Info=False"

Error:-2147467259 Could not find installable ISAM.


    MyDB.ConnectionString = _
        "Provider=Microsoft.Jet.OLEDB.4.0;" & _
        "Data Source=" & App.Path & "\sys.dat" & ";" & _
        "UserName=Admin;" & _
        "PWD=mypass;" & _  
        "Persist Security Info=False"

Error:-2147467259 Could not find installable ISAM.

   - Marc
0
 
LVL 7

Expert Comment

by:_agj_
ID: 9761444
this error comes generally due to the environment, installed version of mdac etc.
As in, i have seen this code run on one sys but not on another.
0
 
LVL 1

Author Comment

by:MarcGraff
ID: 10165188
CleanupPing:
I appriciate the job you are doing. On this question I really do want an answer, but so far nothing has worked. If you or anyone else has any suggestions on how to get this answer please let me know.

   - Marc
0
 
LVL 1

Author Comment

by:MarcGraff
ID: 10301810
I am still interested in this answer if anyone is still with me.

   - Marc
0
 
LVL 1

Author Comment

by:MarcGraff
ID: 10302344
Gave up :(

   - Marc
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

762 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

20 Experts available now in Live!

Get 1:1 Help Now