Results 1 to 8 of 8

Thread: Connection String

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2011
    Posts
    688

    Connection String

    Hi

    I want to make a connection string & it should try to make connection in a certain period of time . If connection successful them o.k else it give message "timeout,unable to make connection within specified time"

    Thanks

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Connection String

    ADO Connection objects can be declared WithEvents.

    Then you can call the Open method passing adAsyncConnect, and Enable a Timer control.

    If the Timer fires before the Connection raises its ConnectComplete event you can call the Cancel method.


    All of this is covered in the MSDN Library CDs that shipped with legal copies of VB6.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2011
    Posts
    688

    Re: Connection String

    Hi

    Isn't there any option of timeout in connection string

    Thanks

  4. #4
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Connection String

    Quote Originally Posted by dilettante View Post
    ADO Connection objects can be declared WithEvents.

    Then you can call the Open method passing adAsyncConnect, and Enable a Timer control.

    If the Timer fires before the Connection raises its ConnectComplete event you can call the Cancel method.


    All of this is covered in the MSDN Library CDs that shipped with legal copies of VB6.
    How do you know it has to do with ADO when that is not even mentioned


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  5. #5
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Connection String

    Quote Originally Posted by jmsrickland View Post
    How do you know it has to do with ADO when that is not even mentioned
    The term "Connection String" is a pretty good hint. That and being in a VB6 forum.

  6. #6
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Connection String

    Oh, OK. I don't know ADO so that's why I asked
    Last edited by jmsrickland; May 29th, 2015 at 02:02 AM.


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  7. #7
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,537

    Re: Connection String

    Quote Originally Posted by dilettante View Post
    ADO Connection objects can be declared WithEvents.

    Then you can call the Open method passing adAsyncConnect, and Enable a Timer control.

    If the Timer fires before the Connection raises its ConnectComplete event you can call the Cancel method.


    All of this is covered in the MSDN Library CDs that shipped with legal copies of VB6.
    Quote Originally Posted by Jagjit View Post
    Hi

    Isn't there any option of timeout in connection string

    Thanks
    Or... you just create the connection object, set the connectionstring, set the ConnectionTimeout property, wrap it in an error handler, and then attempt to open it. If it doesn't open within the time specified by the CommandTimeout, and error will be raised... if the connection is successful, then it opens, and the code continues.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  8. #8
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Connection String

    True enough, though as it says in the manual:

    Make sure the provider to which you are writing code supports the ConnectionTimeout functionality.
    Then if the interval is short enough (5 seconds or less) hanging on a synchronous Open works too. Longer than that and Windows will mark you "unresponsive" (irresponsible?). Plus you have no way to let the user "cancel" a connection attempt that takes too long.
    Last edited by dilettante; May 29th, 2015 at 08:33 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width