Solved

Check Online Access w/VB6 App

Posted on 2014-02-27
3
289 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
ID: 39891594
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
ID: 39892387
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
ID: 39899085
Thank you!
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

680 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