Solved

Delphi XE4 ADORecordset - trouble setting the active connection

Posted on 2013-11-11
2
873 Views
Last Modified: 2013-11-13
Hi, Experts.  I'm new to Delphi XE4.  I have lots of years with Delphi 5, a little with Delphi 2006, but am trying to make the leap to XE4.

I have few Delphi 2006 windows service programs that run fine.  I'm trying to create a new one in XE4, based on one of my existing Delphi 2006 programs.

One change that happened somewhere between 2006 and XE4 is the _Recordset object's _Set_ActiveConnection now takes a parameter of IDispatch instead of string.

In my ignorance, I've simply changed the string parameter to IDispatch and tried typecasting.  (Don't laugh too long.)

I've read a bit of the help file on IDispatch and that gave me no better understanding.

What I'm trying to do in this program is read an encrypted ADO connection string from an INI file, and use that to make a connection to a SQL database to get a set of records that I have to process in the timer event of my service program.

The event log gives me the Microsoft equivalent to "you can't get there from here" when the service program gets to

MyRecordSet._Set_ActiveConnection(FConnectionString);  

// FConnectionString is a typecast IDispatch of a string from reading the ini file.

I'd sure appreciate some direction on how to set the connection string for an ado connection.

Thanks.
0
Comment
Question by:bjones8888
[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 27

Accepted Solution

by:
Sinisa Vuk earned 500 total points
ID: 39640883
You can always create connection object and pass it to Set_ActiveConnection as is here:
aConnection := CoConnection.Create;
aConnection.Open(sConnectionString, '', '', -1);
recs.Set_ActiveConnection(aConnection);
....

Open in new window


if you van to stick with string....
connStr: OleVariant;
recs: _Record;
...
connStr := 'Provider...';
recs.Set_ActiveConnection(connStr);
....

Open in new window

0
 

Author Closing Comment

by:bjones8888
ID: 39646004
It seems to me like the older version of Delphi may have created the connection object "on the fly" if one wasn't specified.

In any event, I'm now successfully using a TAdoConnection object, setting its connection string, and setting Connected to True. Then I use TAdoQuery to do the record processing.

Thank you!
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

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…
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…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month10 days, 3 hours left to enroll

624 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