Solved

Using COM to check a connection

Posted on 2004-09-21
2
227 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
[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 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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

751 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