Solved

VB.net Timer Object to see if connection working

Posted on 2011-09-15
2
372 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:Murray Brown
[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:Murray Brown
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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

635 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