?
Solved

Access database on read only/Access controlled network 200 POINTS!!

Posted on 2003-03-31
6
Medium Priority
?
310 Views
Last Modified: 2010-05-01
Question is similar to http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20409655.html

I have a vb app that needs to access an Access 2000 database on a network controlled Read Only directory.  The admin will not allow me to set any directory to read/write, so that is not an option.  According to the accepted answer at

http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20409655.html

I would not be able to programatically open this database.  I only want to read values from it, that's it.  If this is not possible in a read only directory, how is it possible that I can open that same read only database in the read only directory by just clicking on it and opening it in Access?  Should't I not be able to open it either if it needs that ldb file?  There's got to be a  way to systematically program this! Thanks!
0
Comment
Question by:mchandler
[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
  • 3
  • 3
6 Comments
 
LVL 26

Expert Comment

by:EDDYKT
ID: 8241072
I think you can do that by setting

Dim Cn As ADODB.Connection, DSN As String
   
If Cn Is Nothing Then Set Cn = New ADODB.Connection
Cn.Mode = adModeRead    ' set cn to readonly
Cn.Open DSN ' where dsn is your dsn less

0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 8241096
I use following routine and return the record set


Public Function ReadRecordSet(ByVal DSN As String, ByVal SelectList As String) As ADODB.Recordset
    Dim Cn As ADODB.Connection
   
    On Error GoTo Connection_Failed
    If Cn Is Nothing Then Set Cn = New ADODB.Connection
    Cn.Mode = adModeRead
    Cn.Open DSN
    Dim RS As ADODB.Recordset
   
    Set RS = New ADODB.Recordset
    RS.CursorLocation = adUseClientBatch
    On Error GoTo Read_Failed
    RS.Open SelectList, Cn, adOpenKeyset, adLockBatchOptimistic, adCmdText
    Set RS.ActiveConnection = Nothing
    Set ReadRecordSet = RS
    Set RS = Nothing
    If (Not Cn Is Nothing) Then Set Cn = Nothing
    Exit Function
   
Read_Failed:
    If (Not Cn Is Nothing) Then Set Cn = Nothing
    If Not RS Is Nothing Then Set RS = Nothing
   
Connection_Failed:
    Err.Raise Err.Number, "ReadRecordSet", Err.Description
End Function
0
 
LVL 1

Author Comment

by:mchandler
ID: 8247468
this is what I have put in my code, and I got the message:

Could not lock file.
error number: -2147467259

Thanks again.
Matt



 Dim conImex As Connection
 Dim rsImex As Recordset
   
  Set conImex = New Connection
  Set rsImex = New Recordset
   
 'Establish connection string and open connection
  conImex.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Database.mdb;Mode=Read;Persist Security Info=False"
  conImex.Open
   
 'SQL statement
  strSQL = "SELECT * From tblMaps"
       
  rsImex.CursorLocation = adUseClientBatch
  rsImex.Open strSQL, conImex, adOpenKeyset, adLockBatchOptimistic, adCmdText
0
Technology Partners: 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!

 
LVL 26

Accepted Solution

by:
EDDYKT earned 800 total points
ID: 8247591
Try this

Dim conImex As Connection
Dim rsImex As Recordset
   
 Set conImex = New Connection
 Set rsImex = New Recordset
 
conImex.Mode = adModeRead

'Establish connection string and open connection
conImex.ConnectionString = "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & App.Path & "\Database.mdb;"

conImex.Open
0
 
LVL 1

Author Comment

by:mchandler
ID: 8248086
I took a sick day today, but this seemed to work in a read only directory at home.  I'll try it tommorow morning, and award you the points.  Thanks again for your quick and kind help.


  Dim conImex As Connection
  Dim rsImex As Recordset
   
  Set conImex = New Connection
  Set rsImex = New Recordset
     
  conImex.Mode = adModeRead
  conImex.ConnectionString = "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & App.Path & "\Database.mdb;"
  conImex.Open

  strSQL = "SELECT * From tblMaps"  

  rsImex.Open strSQL, conImex, adOpenForwardOnly, adLockReadOnly
0
 
LVL 1

Author Comment

by:mchandler
ID: 8253940
Thank you for your quick help....it worked! I am giving you an A!
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them.

Question has a verified solution.

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

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…
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 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…
Suggested Courses

765 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