Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Using COM to check a connection

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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

670 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