4

I have a project where most of the layers come from a SQL server. Most of the layers contain pointers to, and/or drop down list for, attributes so that there is consistency in data entry. This project accounts for 80% of my work

My PC was recently rebuilt in Windows 10 and I have a fresh install of QGIS 2.18. That means that I lost all recent history and connections to the database.

When I opened my project, I received the 'Handle Bad Layers' dialogue box for some of my layers. It turns out that the project had been created over time with different paths to the database. I was able to add the layers back to the project, but I have lost the pointers and drop down lists. I would like to get them back.

Luckily I have copies of the project that I can still open on a Windows 7 machine, so I can see what those pointers and lists looked like. I could go through one at a time and recreate what I need, but I would prefer something less manual and less prone to human error. There are 27 layer and each layer has 20-30 attributes.

I've been trying to research .qlr files, but I am not sure I am on the right track.

Can anyone help me, or direct me to some search terms that could help?

  • An Update. The answer provided didn't work for me and I am still researching. I was found that there had been two ways to connect to the database. Recreating the ODBC connections has meant that I can now open the original project and keep working. I now need to rebuild with all tables connecting the same way. – Johanna Mar 22 '18 at 21:24
0

May you can build the layers in a new QGIS project and copy the string for the datasource in the equal colunm in the "Handle Bad Layers" window form the old project. The old ones can provied you helpful information like in this example:

dbname='name' host=localhost port=5432 user='postgres' password='***' sslmode=disable key='id' srid=4326 type=Point table="public"."table" (geom) sql="lang" in ('de', 'en', 'cs', 'pl')

Take also a look at the changeDataSource plugin for QGIS. (https://plugins.qgis.org/plugins/changeDataSource/)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.