Solved

Accessing an access database with a password

Posted on 2003-11-11
26
265 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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
 
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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
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…
Suggested Courses
Course of the Month10 days, 23 hours left to enroll

628 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