Solved

Check Online Access w/VB6 App

Posted on 2014-02-27
3
279 Views
Last Modified: 2014-03-02
I use the following to connect to our server with my vb6 application.  If we have no internet connection it throws an error.  I would like to "test" the connectivity and notify that we have no online access rather than just throw an error:

    Set srvr_conn = New ADODB.Connection
    srvr_conn.Open "Provider=SQLNCLI10;Server=216.185.199.1,1433\SQLExpress;Database=db;Uid=uid;Pwd=pwd;"

Open in new window


Thanks!
0
Comment
Question by:Bob Schneider
3 Comments
 
LVL 9

Accepted Solution

by:
Valliappan AN earned 250 total points
Comment Utility
Look at this:

http://support.microsoft.com/kb/168336

on handle errors for ADO.

Also this:

http://support.microsoft.com/kb/167957/EN

(to handle all errors vb and ADO combined)
0
 
LVL 4

Assisted Solution

by:ravikantninave
ravikantninave earned 250 total points
Comment Utility
Generally I use this Method.
First I check if Internet is connected If yes then goto connection else show error
Function GetHTMLCode(strURL) As String
On Error Resume Next
    Dim strReturn                   ' As String
    Dim objHTTP                     ' As MSXML.XMLHTTPRequest
    If Len(strURL) = 0 Then Exit Function
    Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP")
    objHTTP.Open "GET", strURL, False
    objHTTP.Send                    'Get it.
    strReturn = objHTTP.ResponseText
    Set objHTTP = Nothing
    GetHTMLCode = strReturn
End Function

Open in new window


    Dim strIntConnn As String
    strIntConnn = GetHTMLCode("http://www.google.com")
    If Len(strIntConnn) > 0 Then
      ConnectToDb
else
     MsgBox "Sorry!!!" & vbCrLf & "No Internet Connection Found.  Please Connect Internet First.", vbInformation + vbOKOnly, "System Information :"
endif

Open in new window

0
 

Author Closing Comment

by:Bob Schneider
Comment Utility
Thank you!
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now