The CoInitialize error on IntraWeb using ADO gives you the correct answer.
As I catch from comments on @David answer to this question, there are two things left:
- Where is declared the TComInitialization type, which in turns defines the ciMultiThreaded identifier.
Answer to this is: IWServerControllerBase unit, part of Intraweb.
- Where to change the ComInitialization property of the IWServerController object to get this working.
- The first thing you have to know is the actual class used to construct the IWServerController object is part of your IntraWeb project.
- Next, trying to set this property on a page OnCreate event looks too late (it must be created in the thread you want to initialize COM), my guess is that altering this property at this time is forbidden and will raise an exception, or will be ignored completely.
- Using the Delphi XE VCL for the Web Application wizard I got a unit named ServerController, with the class TIWServerController. After failing to override the constructor, I override the AfterConstruction method to initialize such property, like this
Example:
TIWServerController = class(TIWServerControllerBase)
procedure IWServerControllerBaseNewSession(ASession: TIWApplication;
var VMainForm: TIWBaseForm);
private
protected
//constructor Create; override; //failed!!
public
procedure AfterConstruction; override;
end;
//..
procedure TIWServerController.AfterConstruction;
begin
inherited;
ComInitialization := ciMultiThreaded; //succeded
end;
I then added a button, a label and properly configured ADOConnection (against SQL Server if that matters) and:
procedure TIWForm2.IWButton1Click(Sender: TObject);
begin
try
ADOConnection1.Connected := True;
IWLabel1.Caption := 'Connected';
except
on E:Exception do
IWLabel1.Caption := E.ClassName + ' ' + E.Message;
end;
end;
Hitting the button, produces this:

Hope this is enough to you.