Sunday, 13 November 2016

QGIS 2.4 access .mdb add error


So I followed the instruction here: Can QGIS read an ODBC connection? for adding a .mdb into QGIS. There are great instructions about 1/3 of the way down. But I still can't get it to open. I on Windows 7 with QGIS 2.4 I restarted QGIS and my computer. I am still getting the error: "Invalid Data Source: ODBC:co2014ProdSumm (btw this is the .mdb) is not a valid or recognized data source. "


These are not vector layers nor is this a ESRI personal geodatabase. This is an Access database with 2 tables I need out of it.


I also found a few other posts How to access a .mdb file (Microsoft Access) in Qgis (with windows 7)? How to import info from mdb file into a project?



and this one might be the answer but I don't know what it's talking about: Microsoft Access mdb "is not a valid or recognized data source" in QGIS


Is there any way to add a .mdb into QGIS? Also I do not have Access on my computer.


Edit 1:I hope this clarifies my issue. Each time I get Invalid Data Source: C:...Co 2014 Annual Production Summary-xp.mdb is not a valid or recognized data source. Here is where I added the access connection


Here is where I added the access connection


Trying to add as a vector file add as a vector file


Trying to add a database, I also tried local:host 3000 The error in the pic is the same no matter the source, name etc... I've tried changing all fields around. enter image description here



Answer



Note there are two ways of doing this. The way you are going about doing it is the long way but that is the way I am going to show how to do it here. The other way is by just going to Add Vector Layer and then selecting file and then browsing to where your .mdb file is located and opening the .mdb file.


First, you need to make sure QGIS 32 bit version is being used. Download and install QGIS for Windows 32 bit. You need a 32 bit version of QGIS because Microsoft does not make a 64 bit driver for Access(.mdb). Esri ArcMap is 32 bit too so it can work with .mdb files.


Second, you need to create a DSN(Data Source Name). To create a DSN, Go to your start button and click it.



Start Button


Next in the search box, type %windir%\SysWoW64\odbcad32.exe and click on the odbcad32.exe program.


ODBC Data Source Window


Click on the System DSN tab


enter image description here


Click on the add button to add a dsn so ODBC and Esri Personal Database.mdb can be accessed. Once you click on the Add button a new dialog will appear. On this dialog, select Microsoft Access Driver(*.mdb) and click finish.


Add Access Driver


After clicking finish, another dialog will appear. In this dialog, put QGIS for the Data Source Name.


Data Source Name


Next click on the Select button under Databases. Once you select this button, another dialog will appear.It is the select database dialog.



enter image description here


On this dialog, you need to navigate to your .mdb file. Once you are in the folder the .mdb file will appear in the left box. Select your .mdb file and click OK


Final Select


Now you should see the ODBC Microsoft Access Setup Dialog. The Dialog should show you your .mdb file like the dialog box below.


enter image description here


Now click OK on the dialog box. Also make note, the DATA Source Name is QGIS. We will use this name when setting up an ODBC .mdb / Esri Personal GeoDatabase.mdb. Once you click ok you should see a dialog box like the following, which shows the DSN you just created. Click ok on this dialog box to close it out.


enter image description here


Now open up QGIS 2.4 and go to Add Vector Layer enter image description here


Now, Select database and then select your Encoding you want and then under Database Type select Esri Personal GeoDatabase


enter image description here



Now, on the same dialog, click the New Button


enter image description here


A new dialog box will appear. On this dialog box, fill out the Type, Name and Database fields. For the Type field, select Esri Personal GeoDatabase. For the Name, type whatever you want. For the Database field, type QGIS. Note that QGIS is the same name as the DSN that we created earlier.


enter image description here


Now click on the test button.


enter image description here


If everything is setup correctly, you will see this after clicking on the test button.


enter image description here


Next click ok to close out the test and then click Ok to finish the database connection.


enter image description here



Now you should see the name you gave the connection and once you do, click the Open Button. Once you click open, it will ask for a password. Just click ok, unless the database has a password.


enter image description here


After clicking ok on the password dialog box, you will see a dialog like below:


enter image description here


Select your layer and click ok. After selecting the layer you want and clicking ok you will see another dialog box. This dialog box is for setting coordinate references.


enter image description here


And we are done! You can do this with regular .mdb or Esri Personal GeoDatabase. To do it this way, you need to create a DSN and then set up a connection. There is a simpler way and that is just by going to add vector and making sure File is selected and then just browsing to your .mdb. Note, you need QGIS 32 bit to work with .mdb databases.


enter image description here


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...