Solved

VB.net Timer Object to see if connection working

Posted on 2011-09-15
2
358 Views
Last Modified: 2012-06-27
Hi

In VB.net I connect to a SQL database using the following code.
I want to use a timer object and code to test if the connection works.
How would I do this? What code would I use?
Public Sub oAppend(ByVal oDate As Date, ByVal oText As String, ByVal oNumber As Single)
 
    Dim oSQL As String
    
    On Error GoTo EH
    
    Set con = New ADODB.Connection
    
    con.Open "Provider=SQLOLEDB;Data Source=196.11.247,1884;Network Library=DBMSSOCN;Initial Catalog=test;User ID=llllk3;Password=4lllgg;"

    Set cmd = New ADODB.Command

Open in new window

0
Comment
Question by:murbro
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 500 total points
ID: 36545068
If you are starting your project, I would not start with ADODB. This technology is there mainly to support old types of applications.

This is particularly true when you use SQL Server, since .NET has a library specifically dedicated to SQL Server. Except for connections and commands, you would have to learn a new way of working with databases, but this is the .NET way and the way to work with web applications as well as Windows application. For instance, the Recordset does not exist anymore in that library, and you do not have a permanent connection to the database.

Working with the System.Data.SqlClient library instead of ADODB will provide you not only with a sensible gain in performance, but also with a lot of extra useful features.

As an example, the SqlConnection object has a timeout feature built-in. After a fixed delay, you receive an exception if the application was not able to connect in a timely fashion. No need for a timer, it is there by default.

And before you ask, no, I do not have a good book or web site to recommend to learn how to use the .NET libraries (ADODB is a not a .NET library, it is a bridge to an old COM library). Everybody has his own way of learning new things. Books get outdated to fast to be really useful, and I could suggest you a web site that is excellent for me, but would not be to a level or have a content in accord with your level of expertise and you past experience.
0
 

Author Closing Comment

by:murbro
ID: 36545620
Thanks very much for the advice
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

726 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