Solved

Using COM to check a connection

Posted on 2004-09-21
2
225 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
ID: 12116111
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 Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Suggested Solutions

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

861 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