Testing a SQL Server–VB Connection

Downloads
22562.zip

I want to test a connection from Microsoft Visual Basic (VB) 6.0 to SQL Server. I tried to conduct the test through SQL-DMO's VerifyConnection property but was unsuccessful. Listing 1 shows the code I used. Where did I go wrong?

If you need to know whether your VB—SQL Server connection is working, you can use the PingSQLServerVersion method, as Listing 2 shows. This code executes faster and consumes fewer resources than your script. In addition, VerifyConnection verifies only a connection that has already been made. In the call you make to VerifyConnection, the parameter should be a boolean instead of an int. Also, your code line

oSQLServer.StatusInfoRefetchInterval
(SQLDMOStatInfo_AutoVerifyConnection)
= 10

reduces performance because you're using 10-second intervals instead of 30-second intervals to determine the connection status.

Please or Register to post comments.

IT/Dev Connections

Las Vegas
September 30th - October 4th

Paul ThurottOur Experts will show you:
• Common SQL Server
Problems
• Best Practices for T-SQL
• SQL Server Integration
Services
• Database Development

Come See Mike Otey & Tim Ford in Person!

Early Registration Now Open

From the Blogs
May 9, 2013
blog

My ISO 8601-Compliant Signature 2

My family recently just "officially" announced that we're in the process of adopting a child from South Africa. We're quite excited, of course, but there's a ton of paperwork to do—along with the need for gobs of signatures....More
May 8, 2013
blog

Use SSIS for ETL from Hadoop

In this blog post, Mark Kromer walks you through using SSIS as a way to use ETL techniques using Microsoft's Hadoop on Windows (HDInsight) as a source using Hive connectors...More
Vision road sign
May 6, 2013
blog

Cheaters Never Win, Even in TPC Benchmarks

In this portion of the series on database benchmarking, I want to tell you about one of my favorite aspects of the TPC benchmarks – CHEATING....More
SQL Server Pro Forums

Get answers to questions, share tips, and engage with the SQL Server community in our Forums.