Data could not be retrieved from the database.

tfaulkes

Board Regular
Joined
Jun 4, 2009
Messages
74
I am executing a query and bringing the data into Excel. I just started to get this error and I am not sure why. The error is thrown at .Refresh BackgroundQuery:=False and says Application defined error. It seems to stem from one particular query. I am able to execute others within the same database using the same code (just different commandtext).The microsoft message when trying to query the data manually is: Data could not be retrieved from the dtabase. Check the database server or contact your ..blah. Any input would be very helpful.




Code:
        With .ListObjects.Add(SourceType:=0, Source:=Array( _
            "OLEDB;Provider=Microsoft.ACE.OLEDB.12.0;Password="""";User ID=Admin;Data Source=" & sFULLNAME & "" _
            , _
            ";Mode=Share Deny Write;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password=""""" _
            , _
            ";Jet OLEDB:Engine Type=6;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1" _
            , _
            ";Jet OLEDB:New Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False" _
            , _
            ";Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False;Jet OLEDB:Support Complex D" _
            , "ata=False"), Destination:=.Range("$A$1")).QueryTable
                    .CommandType = xlCmdTable
                    .CommandText = Array(sQRY)
                    .BackgroundQuery = True
                    .SourceDataFile = sFULLNAME
                    .ListObject.DisplayName = "TABLE" & wbMACRO.Sheets.Count
                    .Refresh BackgroundQuery:=False
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

Forum statistics

Threads
1,224,607
Messages
6,179,871
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top