Results 1 to 2 of 2

Thread: Issue getting table data when using PSQL plugin to connect to Postgre database

  1. #1
    Join Date
    Mar 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Issue getting table data when using PSQL plugin to connect to Postgre database

    Hi all,

    I've recently been trying to connect to a PostgreSql database using the QPSQL plugin. I can connect to my database, but can't get info from any queries. The output from the SQLError class is given as following:
    "Error: Relation "node" does not exist"
    Line 1: Select * from Node

    QPSQL: Unable to create query.

    I tried using the SQL Browser demo to connect to my database as well. I have the option to connect using the QPSQL driver. I can connect to the database through here. When I click the arrow by my connection, all of the tables in my database are listed. However, trying to click on any of the tables yields the message "Unable to find table X". Attempting to write a select query in the query browser returns the same error listed above. My source to access the database is listed below...
    Qt Code:
    1. TextStream output(stdout);
    2. QSqlDatabase db = QSqlDatabase::addDatabase(DBDRIVER);
    3. db.setHostName(DBHOST);
    4. db.setDatabaseName(DBNAME);
    5. db.setUserName(USERNAME);
    6. db.setPassword(PASSWORD);
    7. QSqlQuery qry;
    8.  
    9.  
    10. if ( db.open() )
    11. {
    12. qry.exec("select * from Node");
    13.  
    14. QSqlError err = qry.lastError();
    15. QString sErr = err.text();
    16. output << sErr;
    17.  
    18. while(qry.next())
    19. {
    20. QString name = qry.value(1).toString();
    21. output << name;
    22. }
    23. }
    24. return qry;
    25. }
    To copy to clipboard, switch view to plain text mode 

    If it matters I'm running QT 4.6.2 on Windows 7 and attempting to connect to PostgreSql 8.4 on Ubuntu. I can successfully get queries out of the pgAdmin tool that was bundled with PostgreSql. Any help is greatly appreciated. Thank you for your time and consideration.

  2. #2
    Join Date
    Mar 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Issue getting table data when using PSQL plugin to connect to Postgre database

    nevermind, the similar thread function pointed me to this

    http://www.qtcentre.org/threads/2777...(due-to-casing)

    Turns out I was just having a capitalization issue with my table names.

Similar Threads

  1. QSqlDatabase - How to connect to multiple database?
    By cutie.monkey in forum Qt Programming
    Replies: 4
    Last Post: 10th March 2010, 12:03
  2. Replies: 1
    Last Post: 3rd February 2010, 06:01
  3. how to connect to a microsoft access database?
    By mismael85 in forum Qt Programming
    Replies: 3
    Last Post: 7th March 2008, 09:25
  4. Error compiling psql plugin
    By vieraci in forum Installation and Deployment
    Replies: 4
    Last Post: 7th October 2007, 02:49
  5. My application can't connect to database when deploy it???
    By gtthang in forum Installation and Deployment
    Replies: 1
    Last Post: 15th February 2006, 11:01

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.