473,406 Members | 2,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to get data from Access database without closing accdb ?

215 128KB
Ok, this is my next step to learn, I want to ask some information about how to get all data fastest-medthod from Access to excel without having to close it ?

currently I use built-in function "Import from Access" with connection string (given automatically by excel)
Expand|Select|Wrap|Line Numbers
  1. Provider=Microsoft.ACE.OLEDB.12.0;
  2. User ID=Admin;
  3. Data Source=D:\data WS\WS admin.accdb;
  4. Mode=Share Deny Write;
  5. Extended Properties="";
  6. Jet OLEDB:System database="";
  7. Jet OLEDB:Registry Path="";
  8. Jet OLEDB:Engine Type=6;
  9. Jet OLEDB:Database Locking Mode=0;
  10. Jet OLEDB:Global Partial Bulk Ops=2;
  11. Jet OLEDB:Global Bulk Transactions=1;
  12. Jet OLEDB:New Database Password="";
  13. Jet OLEDB:Create System Database=False;
  14. Jet OLEDB:Encrypt Database=False;
  15. Jet OLEDB:Don't Copy Locale on Compact=False;
  16. Jet OLEDB:Compact Without Replica Repair=False;
  17. Jet OLEDB:SFP=False;
  18. Jet OLEDB:Support Complex Data=False;
  19. Jet OLEDB:Bypass UserInfo Validation=False
  20.  
but this method force me to close access when I have to press "Refresh all" to refresh all data on all table connections.

are there anyother method that let's me pull all data (refresh or whatever) without closing access :-?

edit: I found out I can change "Mode=Share Deny None" to fullfill my need.
sothat I want to ask 1 more question
if we use VBA code to pull data from Access, will it be faster than built-in connections ?
Nov 30 '15 #1
8 2303
zmbd
5,501 Expert Mod 4TB
As you have discovered
>> Mode=Share Deny None (Related thread)
is the solution to having to close the Access file.

Unfortunately, answering the question as to which is faster... "both/and/or"
That is to say, it all depends on what your dataset looks like and it really doesn't matter if you link to the Access backend via VBA or Linked table.
Nov 30 '15 #2
zmbd
5,501 Expert Mod 4TB
Just a thought, MS Query.
This might be a slightly better method....
https://bytes.com/topic/excel/answer...e-excel-2010-a

The connection string would be a tad different... something along these lines (caution air code):
Expand|Select|Wrap|Line Numbers
  1. ODBC;DSN=MS Access Database;DBQ=(path to file);
  2. DefaultDir=(Path to paremt);
  3. DriverId=25;
  4. FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;
and, of course, there would be a different SQL for the recordset.

This shouldn't hold the access file hostage and should give the same ability to pull the data...
Nov 30 '15 #3
hvsummer
215 128KB
@zmbd: ok I got it,

I've tho that ADO or DAO get recordset then push everything into an 2 dimension array next loop thro them and decorate the result in worksheet
<--- can be faster. But i think that could be bad idea :D
Nov 30 '15 #4
zmbd
5,501 Expert Mod 4TB
Unless you are working with a small record set memory may be a limitation.
Within Access you have the Recordset.GetRows Method (DAO) that will read the records to a 2D-Array. I've not personally found a good use for this; however, there is an example in the link

The downside is returning the data to the recordset if needed... Bytes>how to transfer a 2d array into a table however, as Stewart Ross points out in his post, Excel has a way to do move the data from an array to a the ranges which may be applicable.

If you will search Bytes, there are a number of threads dealing with moving a recordset to an excel workbook and then formatting the results.

I have worked on one or two that inserted a worksheet, copied the data to the worksheet, updated the range-names to point at the new worksheet, deleted the placeholder, and hid the worksheet with the data. I'll have to dig it out, if I still have it and if the file will open in Acc2013!

-z
Nov 30 '15 #5
hvsummer
215 128KB
in fact, If we have enough time, we can code everything for each cells (value, formula, formating) in workbook.

transfer array into table, I think we can use
Expand|Select|Wrap|Line Numbers
  1. .resize = application.transpose(array)
that will be the fastest way
Dec 1 '15 #6
hvsummer
215 128KB
Aw, I tho that Mode=Share Deny None could help me out, but when run vba code in access, it appear the dialog "the database has been placed in state by "user" on abc that prevent it from open or lock" ==

Trying to find the solution 3hrs ago, but nowhere could help ==
Dec 1 '15 #7
zmbd
5,501 Expert Mod 4TB
Ok, most likely cause is that you are instancing the Excel from the same database that you are pulling the data from, the database has been opened in exclusive mode.
Ribbon>File>Options>>Client Settings>>Advanced>> Default Open Mode

See what that is set to. I have mine set to Shared by default as I'm always in and out of things.

There is some old code (( ACC: How to Determine If a Database Is Open Exclusively )) that one can use to determine if the file is opened as exclusive.

The method I use is:
<ctrl><g>
Expand|Select|Wrap|Line Numbers
  1. ?(currentdb.Containers!forms.allpermissions and dbsecfullaccess) = dbsecfullaccess
If returns "True" then it should be in a shared state.

IN the production databases, I split the front from the back and then make my calls/links to the backend as needed; thus, sharing the data portion of the database. This may also be a solution for you.
Dec 1 '15 #8
hvsummer
215 128KB
@zmbd:
I alway set the open mode to shared altho only me using database ==
but I findout what happen.

first thing I've open the attachment dialog in attachment field when I debug another code inside vba to test why the ADO.recordset2 return "object does not support this method".

I tho that db was placed in state. but I wrong, I've tricked by microsoft funny system ==

I rewrote the code for ADO.recordset2 and everything work fine.

next time I'll remember not to open any dialog while debug another error == it'll lead to big missurender...
Dec 2 '15 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: MAB71 | last post by:
There should be a way to copy an access database ( .mdb file ) without closing connections to it. Unfortunately the FileCopy statement in VB gives an error if users are connected to the db. But I...
2
by: Red Golpe | last post by:
Is it possible to read (queries, tables...) from a remote database (ie, using its URL) without using ASP? I mean, I would like to write a web page which gets data from an Access db which actually...
1
by: programmerKid | last post by:
Hi, I am trying to open mdb file to view tables in it but when I open mdb file it run form in it by itself, as a startup point. Can anyone please tell me how to view and change in tables and...
3
by: Familjen Karlsson | last post by:
Here is an example from the help on the keword OleDbConnection, in VB.Net, they don't give the path to the database just the word localhost. How can it connect to the database without knowing where...
1
by: Daniel Manes | last post by:
Some facts: 1) I have an Access database (.mdb file) sitting on my harddrive. 2) I have Visual Studio 2005, Sql Server Express, and Sql Server Management Studio Express. 3) I do *not* have...
1
by: chuckylefrek | last post by:
I have a page that allows users to update their data. One of the items of data is an image. Therefore the update page includes an <input type="file"> field to allow them to choose a different...
0
by: jackvel | last post by:
Hi Dudes... I want to connect the Access database with VB 6.0 without using DataControl and ADODC.. Which option should i use.? Plz send me the detailed procedure of doing the same.. Plz...
1
by: elma.arsalan | last post by:
Hello: Does anyone know whether it is possible to roll back MS Access database without loosing any data? Or can a roll back be undone (kinda odd). Any comment would be appreciated.
30
vikas1111
by: vikas1111 | last post by:
This is the code which i have written..... Option Explicit Dim c As New ADODB.Connection Dim cm As ADODB.Command Dim rs As New ADODB.Recordset Private Sub regno_Change() c.Open...
1
by: kennethrich047x | last post by:
Does anyone know of a program/option/tool to repair a microsoft access database that can be run from command line (I don't want any user interaction, I want to be able to schedule it). The...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.