Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Accessing an access database with a password

Posted on 2003-11-11
26
Medium Priority
?
272 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
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…
Suggested Courses

722 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