Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 278
  • Last Modified:

Accessing an access database with a password

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
MarcGraff
Asked:
MarcGraff
  • 12
  • 5
  • 4
  • +2
4 Solutions
 
vinnyd79Commented:
try:

MyDB.ConnectionString  = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source= " & App.Path & "\sys.mdb;" & "Jet OLEDB:Database Password=myPassword;"
0
 
SethiCommented:
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
 
MarcGraffAuthor Commented:
Error: -2147467259 Could not find installable ISAM.

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


   - Marc
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
vinnyd79Commented:
You should be using atleast MDAC 2.5
0
 
MarcGraffAuthor Commented:
MDAC 2.5?

   - Marc
0
 
MarcGraffAuthor Commented:
Microsoft Data Access Components?

   - Marc
0
 
MarcGraffAuthor Commented:
I am using v3.52 if you are referring to Microsoft Data Access Components
0
 
vinnyd79Commented:
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
 
MarcGraffAuthor Commented:
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
 
vinnyd79Commented:
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
 
MarcGraffAuthor Commented:
Using ActiveX v2.7, go the same "Error: -2147467259 Could not find installable ISAM."

:(

   - Marc
0
 
vinnyd79Commented:
Is it an access97 database?
0
 
Farzad AkbarnejadCommented:
Hello
Try to use DAO. Use Workspace object in DAO to setup password then use wks.opendatabase method.

-FA
0
 
_agj_Commented:
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
 
SethiCommented:
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
 
MarcGraffAuthor Commented:
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
 
SethiCommented:
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
 
_agj_Commented:
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
 
MarcGraffAuthor Commented:
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
 
_agj_Commented:
the passwrd string isnt Password=
it is:

                           & ";PWD=mypass" _
0
 
MarcGraffAuthor Commented:
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
 
_agj_Commented:
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
 
MarcGraffAuthor Commented:
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
 
MarcGraffAuthor Commented:
I am still interested in this answer if anyone is still with me.

   - Marc
0
 
MarcGraffAuthor Commented:
Gave up :(

   - Marc
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

  • 12
  • 5
  • 4
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now