Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Connect SqlServer open funcation nerver return
Forum Updated to NodeBB v4.3 + New Features

Connect SqlServer open funcation nerver return

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 1.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    youyouli1986
    wrote on last edited by
    #1

    QSqlDatabase's open function will nerver return when i set wrong SqlServer's IP address. how can i make open function return within the specified time?

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      Did you check on QSqlDatabase::setConnectOptions with SQL_ATTR_CONNECTION_TIMEOUT ?

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      0
      • Y Offline
        Y Offline
        youyouli1986
        wrote on last edited by
        #3

        Yes, I use setConnectOptions("SQL_ATTR_LOGIN_TIMEOUT=3;SQL_ATTR_CONNECTION_TIMEOUT=60") before open.
        It still need about 1 minute to report open failed...

        1 Reply Last reply
        0
        • dheerendraD Offline
          dheerendraD Offline
          dheerendra
          Qt Champions 2022
          wrote on last edited by
          #4

          What I understand is that you are setting the login time out as 3 and conn time out as 60. Your expectation is that it should return in 3 secs. It is trying to login and connect. In your case it is wrong IP itself. So it is not even in to login phase. It is still trying to connect to IP which it is not able to find. It is working according to timeouts. Did you try setting conntimeout to some lesser value like 10 secs etc ?

          Dheerendra
          @Community Service
          Certified Qt Specialist
          http://www.pthinks.com

          1 Reply Last reply
          0
          • Y Offline
            Y Offline
            youyouli1986
            wrote on last edited by
            #5

            Yes, I try to use this options: setConnectOptions(“SQL_ATTR_LOGIN_TIMEOUT=30;SQL_ATTR_CONNECTION_TIMEOUT=3”), but nothing change. It seems that options doesn't apply!
            [quote author="Dheerendra" date="1407987770"]What I understand is that you are setting the login time out as 3 and conn time out as 60. Your expectation is that it should return in 3 secs. It is trying to login and connect. In your case it is wrong IP itself. So it is not even in to login phase. It is still trying to connect to IP which it is not able to find. It is working according to timeouts. Did you try setting conntimeout to some lesser value like 10 secs etc ?[/quote]

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved