Board index » cppbuilder » Getting access violation with TADOConnection in a Console Based App
Eddie Ludema
![]() CBuilder Developer |
Getting access violation with TADOConnection in a Console Based App2003-11-04 02:11:22 PM cppbuilder40 Hello all, I have a (hopefully) quick and easy question for all you experts and newbies that are past my knowledge level. I'm trying to write a console app, with the good ol' int main(...) function, which I setup using the New Console App Wizard. I need to be able to use the VCL component TADOConnection, though, and am getting access violations. In the wizard, I've made sure that Use VCL, Multi-threaded and Console Application are all checked... I've tried importing a Form and a Data Module and putting the TADOConnection object there, but it still crashes. If I replace TADOConnection with a different VCL object (like I just tried TTimer), it goes through just fine. Any clues? This is the basic code that I have, which crashes. Any help would be greatly appreciated. Thanks much, Eddie Ludema //--------------------------------------------- #include <vcl.h> #include <ADOdb.hpp> #include <conio.h> #pragma hdrstop #pragma argsused void initialize(void); void cleanPending(AnsiString RequestKey); void cleanUp(void); // G L O B A L S TADOConnection *ADOConnection; TADOQuery *gQ; int main(int argc, char* argv[]) { if (argc < 2) { // print something out showing command-line syntax exit(0); } // Connect to Database /* It crashes on this next line, when actually trying to allocate the space for the VCL object - I get a nice access violation... obj = new TOBJ(NULL) or (0) don't work either - some problem - and of course it doesn't take (this) - it won't compile with that If I trace into the line, it just hangs/freezes... If I try to just let it run, it gives me the access violation... */ ADOConnection = new TADOConnection(Application); // or (NULL) or (0) // Setup ADOConnection properties... blah blah... // delete ADOConnection <- if I can ever get that far :) return 0; } //--------------------------------------------- |