Share via

SQL Server Handshake

Anonymous
2013-10-21T09:44:09+00:00

Hi

I am having a problem with some code and I believe that it cannot connect with the SQL server and this makes my Microsoft Access Databases freeze.

I have a form with an Ontimer event procudure.

What I am after is some sort of code that checks the odbc or SQL connection and then when it confirms there is a connection, it then runs the rest of the code.

Any suggestions?

Regards

Aaron

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

3 answers

Sort by: Most helpful
  1. Anonymous
    2013-10-22T15:04:23+00:00

    Thanks Bill.

    Do you have any examples of the code for the timeout?

    What does your code look like now? Usually you just add the ConnectTimeout. But there are lots of ways to connect. Here is one example Where a user name and password are needed.

    Dim cnn As ADODB.Connection

    'Prompt for username and password (set prompt first):

    cnn.Provider = "sqloledb"

    cnn.Properties("Prompt") = adPromptAlways

    cnn.ConnectionTimeout = 30

    cnn.Open "Data Source=MySever;Initial Catalog=MyDatabase;"

    A good source for connection strings is http://www.carlprothman.net/Default.aspx?tabid=81

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2013-10-22T07:45:23+00:00

    Thanks Bill.

    Do you have any examples of the code for the timeout?

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2013-10-21T19:11:44+00:00

    Make sure your connection string includes a timeout and that the timeout is not zero. Otherwise, it will attempt to connect forever. Then put a break in the event and step through it when it breaks.

    Was this answer helpful?

    0 comments No comments