Click here to Skip to main content
16,007,111 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionWhat's wrong with my code?? Pin
LoveInSnowing4-Oct-01 15:58
LoveInSnowing4-Oct-01 15:58 
AnswerRe: What's wrong with my code?? Pin
Brendan Tregear4-Oct-01 16:21
Brendan Tregear4-Oct-01 16:21 
GeneralRe: What's wrong with my code?? Pin
LoveInSnowing4-Oct-01 17:02
LoveInSnowing4-Oct-01 17:02 
AnswerRe: What's wrong with my code?? Pin
Christian Graus4-Oct-01 17:11
protectorChristian Graus4-Oct-01 17:11 
GeneralRe: Also Pin
Brendan Tregear4-Oct-01 17:16
Brendan Tregear4-Oct-01 17:16 
GeneralRe: Also Pin
Christian Graus4-Oct-01 17:18
protectorChristian Graus4-Oct-01 17:18 
GeneralRe: What's wrong with my code?? Pin
LoveInSnowing4-Oct-01 17:20
LoveInSnowing4-Oct-01 17:20 
GeneralRe: What's wrong with my code?? Pin
Christian Graus4-Oct-01 17:39
protectorChristian Graus4-Oct-01 17:39 
The following code will translate an error number for you

LPVOID lpMsgBuf;
FormatMessage(
    FORMAT_MESSAGE_ALLOCATE_BUFFER |
    FORMAT_MESSAGE_FROM_SYSTEM |
    FORMAT_MESSAGE_IGNORE_INSERTS,
    NULL,
    0x80004005,  // the error number
    0, // Default language
    (LPTSTR) &lpMsgBuf,
    0,
    NULL
);
// Process any inserts in lpMsgBuf.
// ...
// Display the string.
MessageBox( NULL, (LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION );
// Free the buffer.
LocalFree( lpMsgBuf );


In this case it is 'unspecified error', which is what ADO always seems to give ( but it could well come from elsewhere all the same ).

Changing your code as you have done is obviously a step forward, no need for a pointer, plus an ugly memory leak. You should do the same for your FileDialog, or at least delete the thing if people press cancel.

Are you trying to run in F5 ( debug ) mode ? Are you pressing cancel and letting the debugger show you where it is crashing ? If the above code is crashing ( just a domodal() call, then it's dying in the dialog code, and I would continue to maintain in your ADO code. You should set a break point and step through the OnInitDialog as a first step. Are you closing your connection to the database ? It may well be crashing the second time because your first connection is still open.


Also your database path is not absolute, if something else in the dialog is changing the current directory, that will also mean it cannot find the file and will crash.


Christian

As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.

Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
GeneralRe: What's wrong with my code?? Pin
LoveInSnowing4-Oct-01 18:30
LoveInSnowing4-Oct-01 18:30 
GeneralRe: What's wrong with my code?? Pin
Christian Graus4-Oct-01 18:39
protectorChristian Graus4-Oct-01 18:39 
GeneralFilling a Solid Rect Pin
Bret Faller (home)4-Oct-01 15:10
Bret Faller (home)4-Oct-01 15:10 
GeneralRe: Filling a Solid Rect Pin
Mike Nordell4-Oct-01 17:54
Mike Nordell4-Oct-01 17:54 
GeneralRe: Filling a Solid Rect Pin
Chris Losinger4-Oct-01 18:03
professionalChris Losinger4-Oct-01 18:03 
GeneralRe: Filling a Solid Rect Pin
Bret Faller (home)4-Oct-01 18:14
Bret Faller (home)4-Oct-01 18:14 
GeneralRe: Filling a Solid Rect Pin
Jon Hulatt4-Oct-01 22:58
Jon Hulatt4-Oct-01 22:58 
GeneralRe: Filling a Solid Rect Pin
Bret Faller5-Oct-01 6:46
Bret Faller5-Oct-01 6:46 
GeneralRight click on taskbar button. Pin
Christian Graus4-Oct-01 13:44
protectorChristian Graus4-Oct-01 13:44 
GeneralRe: Right click on taskbar button. Pin
Mike Nordell4-Oct-01 14:07
Mike Nordell4-Oct-01 14:07 
GeneralRe: Right click on taskbar button. Pin
Christian Graus4-Oct-01 14:40
protectorChristian Graus4-Oct-01 14:40 
GeneralRe: Right click on taskbar button. Pin
Mike Nordell4-Oct-01 15:17
Mike Nordell4-Oct-01 15:17 
QuestionMaximized MDI Child window flicker? Pin
gh4-Oct-01 13:10
gh4-Oct-01 13:10 
GeneralCRichEditView Pin
4-Oct-01 12:45
suss4-Oct-01 12:45 
GeneralRe: CRichEditView Pin
Tomasz Sowinski4-Oct-01 12:53
Tomasz Sowinski4-Oct-01 12:53 
QuestionHelp button on tool window titlebar? Pin
4-Oct-01 12:18
suss4-Oct-01 12:18 
GeneralCatching special key-presses in an ActiveX within IE Pin
4-Oct-01 11:54
suss4-Oct-01 11:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.