Solved

Using COM to check a connection

Posted on 2004-09-21
2
221 Views
Last Modified: 2010-04-05
Hi,

How can I check a connection using COM. I have the following routine:-

function CustomCreateUDLFile(aUDLPath : WideString) : Boolean;
var
 DataInit : IDataInitialize;

begin

  try
    DataInit := CreateComObject(CLSID_DataLinks) as IDataInitialize;
    OleCheck(DataInit.WriteStringToStorage(PWideChar(aUDLPath),PWideChar(PromptDataSource(Application.Handle,'')), CREATE_NEW));

    Result := True;

    // at this point I want to check if the connection string brought back is valid
   >>> ??? ala pressing the test button on the udl form.

  except

   Result := False;

  end;

The reason I don't want to use an ADO connection, is that this function is in a seperate shared unit. I know that it would be easier to create an ado connection and try and connect, but is the other option possible?

Thanks,
Dion.
end;
0
Comment
Question by:Diono
2 Comments
 
LVL 17

Accepted Solution

by:
Wim ten Brink earned 150 total points
Comment Utility
I don't think there is any way to avoid creating a test connection. But I don't see any real problem here. If you can use IDataInitialize then you can also use _Connection from the ADOInt unit or ADODB_TBL unit instead. Just use CoConnection.Create to create a connection and use it to test it.
If you created ADODB_TBL based on the ADODB type library in Delphi, I hope you created it without the component wrappers. In that case, you can reduce the additional unit overhead in this unit to just Windows, ActiveX, Classes and ComObj.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now