Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Using COM to check a connection

Posted on 2004-09-21
2
Medium Priority
?
231 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 450 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses

971 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