Solved

VB.net Timer Object to see if connection working

Posted on 2011-09-15
2
366 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
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…

734 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