E
einat lapid
I have a wierd problem working with ADO.NET and DAO PIA in the same
project - it seems that ADO.NET is causing the DAO objects
to be destructed. Once I open ADO.NET connection, the DAO objecucts seems
destructed (at least thier native part) and I get
Unhandled Exception: System.Runtime.InteropServices.COMException
(0x800A0D5C): O
bject invalid or no longer set.
The funny thing about it is that it happened only in release build when run
outside of the VS 2005 IDE.
The repro code is below. Any idea how to work around this problem ?
Thanks,
Einat
using System;
using System.Text;
using dao;
using System.Data;
using System.Data.SqlClient;
using System.Runtime.InteropServices;
namespace AccessDataTransfer
{
class Program
{
static void Main(string[] args)
{
String Sourcedbstr = "c:\\1.mdb";
String DestConnectionStr = @"Data Source=localhost;Integrated
Security=SSPI;Initial Catalog=pubs";
String TableName = "Foo";
//dao connection
dao.DBEngineClass engineClass = new DBEngineClass();
dao.Workspace workSpace =
engineClass.CreateWorkspace("WorkSpace", "Admin", "",
WorkspaceTypeEnum.dbUseJet);
dao.Database Sourcedb = workSpace.OpenDatabase(Sourcedbstr,
Type.Missing, true, null);
dao.Recordset SourceRecordSet =
Sourcedb.OpenRecordset(TableName, Type.Missing, Type.Missing, Type.Missing);
//ADO.NET connection that invalidate the DAO objects
SqlConnection DestConnection = new
SqlConnection(DestConnectionStr);
DestConnection.Open();
Now manipulate dao object and fails
TableDef tblDef = Sourcedb.TableDefs[TableName]; //fails
here
}
}
}
project - it seems that ADO.NET is causing the DAO objects
to be destructed. Once I open ADO.NET connection, the DAO objecucts seems
destructed (at least thier native part) and I get
Unhandled Exception: System.Runtime.InteropServices.COMException
(0x800A0D5C): O
bject invalid or no longer set.
The funny thing about it is that it happened only in release build when run
outside of the VS 2005 IDE.
The repro code is below. Any idea how to work around this problem ?
Thanks,
Einat
using System;
using System.Text;
using dao;
using System.Data;
using System.Data.SqlClient;
using System.Runtime.InteropServices;
namespace AccessDataTransfer
{
class Program
{
static void Main(string[] args)
{
String Sourcedbstr = "c:\\1.mdb";
String DestConnectionStr = @"Data Source=localhost;Integrated
Security=SSPI;Initial Catalog=pubs";
String TableName = "Foo";
//dao connection
dao.DBEngineClass engineClass = new DBEngineClass();
dao.Workspace workSpace =
engineClass.CreateWorkspace("WorkSpace", "Admin", "",
WorkspaceTypeEnum.dbUseJet);
dao.Database Sourcedb = workSpace.OpenDatabase(Sourcedbstr,
Type.Missing, true, null);
dao.Recordset SourceRecordSet =
Sourcedb.OpenRecordset(TableName, Type.Missing, Type.Missing, Type.Missing);
//ADO.NET connection that invalidate the DAO objects
SqlConnection DestConnection = new
SqlConnection(DestConnectionStr);
DestConnection.Open();
Now manipulate dao object and fails
TableDef tblDef = Sourcedb.TableDefs[TableName]; //fails
here
}
}
}