Home All Groups Group Topic Archive Search About

Problem with ADO.NET and dao pia in the same project

Author
4 Mar 2006 7:55 AM
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



        }



    }

}

Author
4 Mar 2006 5:35 PM
William (Bill) Vaughn
And you're using DAO because?

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

Show quote
"einat lapid" <e_la***@hotmail.com> wrote in message
news:eP$k%23D2PGHA.2300@TK2MSFTNGP15.phx.gbl...
>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
>
>
>
>        }
>
>
>
>    }
>
> }
>
>
>
>
>
>
Author
6 Mar 2006 11:05 PM
Gil Lapid Shafriri
I need to move data from Access (also Access 97) to SQL


Show quote
"William (Bill) Vaughn" <billvaRemoveT***@nwlink.com> wrote in message
news:erOp$H7PGHA.720@TK2MSFTNGP14.phx.gbl...
> And you're using DAO because?
>
> --
> ____________________________________
> William (Bill) Vaughn
> Author, Mentor, Consultant
> Microsoft MVP
> INETA Speaker
> www.betav.com/blog/billva
> www.betav.com
> Please reply only to the newsgroup so that others can benefit.
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
> __________________________________
>
> "einat lapid" <e_la***@hotmail.com> wrote in message
> news:eP$k%23D2PGHA.2300@TK2MSFTNGP15.phx.gbl...
>>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
>>
>>
>>
>>        }
>>
>>
>>
>>    }
>>
>> }
>>
>>
>>
>>
>>
>>
>
>

AddThis Social Bookmark Button