Solved

Accessing an access database with a password

Posted on 2003-11-11
26
251 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

770 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