ado problem 
Author Message
 ado problem

I am wrote the following code for creating the MDB file, creating the
TABLES and fields dynamically in an MFC dialog bases application.

The problem is that I get access violation exception after executing
the adocommand.Execute(NULL, NULL, 1) function.

void foo()
{
        DeleteFile("c:\\new.mdb");
        OleInitialize(NULL);
        _Catalog catalog;
        if(!catalog.CreateDispatch("ADOX.Catalog.2.5"))
        {
                return;
        }

        //Set ActiveConnection of Catalog to this string
        CString sTest("Provider=Microsoft.JET.OLEDB.4.0;""Data source =
c:\\new.mdb");
        catalog.Create(sTest);

        _Command adocommand;
        if(!adocommand.CreateDispatch("ADODB.Command.2.5"))
        {
                return;
        }

        VARIANT var = catalog.GetActiveConnection();
        adocommand.SetActiveConnection(var);
        CString sSQL("CREATE TABLE ATTRIB (OfficeId TEXT(20),
OfficeName TEXT(10))");
        adocommand.SetCommandText(sSQL);

        adocommand.Execute(NULL, NULL, 1);
//Here I get access violation

        adocommand.ReleaseDispatch();

        catalog.ReleaseDispatch();
        OleUninitialize();

Quote:
}

I need some help to resolve this.

Thanks

-George

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Wed, 07 May 2003 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. ATL / ADO problems while closing connection

2. free threaded ATL, MTS, ADO problem

3. Wierd ADO problem

4. Multi-threaded ADO problem in VC++

5. An ADO Problem

6. ADO problem

7. CHAR, adVarWChar, ADO problem.

8. ADO problems

9. ADO Problem with calling a stored procedure in MS Access 2000

10. COM / ADO - Problems while closing connection

11. ADO problem accessing dBASE tables

12. |||||||||| ADO : PROBLEM WITH MoveFirst AND EndOfFile under Visual C++ 6.0 |||||||||||

 

 
Powered by phpBB® Forum Software