M
ML
Hello,
I have some small code that opens a connection to an oledb-provider and
opens a recordset. Then creates a delegate to a RecordChangeComplete event
on the recordset.
When I put this code in a service (have tried both OnStart and in a separate
thread) I never get any RecordChangeComplete events. Although using the
exact same code in a form application the event works fine.
In both cases I can see that the oledb-provider is sending the right events,
but it seems they are trapped by the service somehow.
I have used the provider in services (written in C++) before, but never
using ADO / ADO.NET and it has always worked fine.
So what is ADO doing that behaves differently in a service-application than
in a Forms-application?
The code in the service looks like this:
protected override void OnStart(string[] args)
{
m_cn = new Connection();
m_rs = new Recordset();
m_cn.Open(Providerstring, "", "", 0);
m_rs.Open(Tablestring, m_cn, CursorTypeEnum.adOpenDynamic,
LockTypeEnum.adLockReadOnly, 0);
ADODB.RecordsetEvents_RecordChangeCompleteEventHandler delRecordComplete
= new
RecordsetEvents_RecordChangeCompleteEventHandler(RecordChangeComplete);
m_rs.RecordChangeComplete += delRecordComplete;
}
/Morgan L
I have some small code that opens a connection to an oledb-provider and
opens a recordset. Then creates a delegate to a RecordChangeComplete event
on the recordset.
When I put this code in a service (have tried both OnStart and in a separate
thread) I never get any RecordChangeComplete events. Although using the
exact same code in a form application the event works fine.
In both cases I can see that the oledb-provider is sending the right events,
but it seems they are trapped by the service somehow.
I have used the provider in services (written in C++) before, but never
using ADO / ADO.NET and it has always worked fine.
So what is ADO doing that behaves differently in a service-application than
in a Forms-application?
The code in the service looks like this:
protected override void OnStart(string[] args)
{
m_cn = new Connection();
m_rs = new Recordset();
m_cn.Open(Providerstring, "", "", 0);
m_rs.Open(Tablestring, m_cn, CursorTypeEnum.adOpenDynamic,
LockTypeEnum.adLockReadOnly, 0);
ADODB.RecordsetEvents_RecordChangeCompleteEventHandler delRecordComplete
= new
RecordsetEvents_RecordChangeCompleteEventHandler(RecordChangeComplete);
m_rs.RecordChangeComplete += delRecordComplete;
}
/Morgan L